Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
tevanoff committed Oct 26, 2023
1 parent a4aedce commit f19982c
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/write-archive/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ describe('writeTestResult', () => {
diffThreshold: 5,
pauseAnimationAtEnd: true,
viewports: [720],
},
new Map<string, string>()
}
);
expect(fs.ensureDir).toHaveBeenCalledTimes(1);
expect(fs.outputFile).toHaveBeenCalledTimes(2);
Expand Down Expand Up @@ -53,7 +52,12 @@ describe('writeTestResult', () => {
childNodes: [
{
attributes: {
src: '/bogano',
src: '/home/',
},
},
{
attributes: {
src: '/img?src=some-path',
},
},
],
Expand All @@ -63,34 +67,40 @@ describe('writeTestResult', () => {
childNodes: [
{
attributes: {
src: '/coruscant',
src: '/home/index.html',
},
},
{
attributes: {
src: '/img-fe2b41833610050d950fb9112407d3b3.png',
},
},
],
};

const sourceMapping = new Map<string, string>();
sourceMapping.set('/bogano', '/coruscant');

const expectedBuffer = Buffer.from(JSON.stringify(expectedMappedJson));

await writeTestResult(
// the default output directory in playwright
{ title: 'Toy Story', outputDir: resolve('test-results/toy-story-chromium') } as TestInfo,
{ home: Buffer.from(JSON.stringify(storyJson)) },
{
'http://localhost:3000/home': {
'http://localhost:3000/home/': {
statusCode: 200,
body: Buffer.from(JSON.stringify(storyJson)),
},
'http://localhost:3000/img?src=some-path': {
statusCode: 200,
body: Buffer.from(JSON.stringify(storyJson)),
contentType: 'image/png',
},
},
{ viewports: [720] },
sourceMapping
{ viewports: [720] }
);

expect(fs.ensureDir).toHaveBeenCalledTimes(1);
expect(fs.outputJson).toHaveBeenCalledTimes(1);
expect(fs.outputFile).toHaveBeenCalledTimes(2);
expect(fs.outputFile).toHaveBeenCalledTimes(3);
expect(fs.outputFile).toHaveBeenCalledWith(
resolve('./test-results/chromatic-archives/archive/toy-story-home.snapshot.json'),
expectedBuffer
Expand Down Expand Up @@ -123,8 +133,7 @@ describe('writeTestResult', () => {
} as TestInfo,
{ home: Buffer.from('Chromatic') },
{ 'http://localhost:3000/home': { statusCode: 200, body: Buffer.from('Chromatic') } },
{ viewports: [720] },
new Map<string, string>()
{ viewports: [720] }
);
expect(fs.ensureDir).toHaveBeenCalledTimes(1);
expect(fs.outputFile).toHaveBeenCalledTimes(2);
Expand Down

0 comments on commit f19982c

Please sign in to comment.