Skip to content

Commit cc34849

Browse files
committed
test(jest-snapshot): add new case for inline snapshot behaviour
1 parent d0d66d4 commit cc34849

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap

+14
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ test('handles property matchers', () => {
118118
119119
`;
120120
121+
exports[`indentation is correct in the presences of existing snapshots, when the file is correctly formatted by prettier: existing snapshot 1`] = `
122+
it('is true', () => {
123+
expect(true).toMatchInlineSnapshot(\`true\`);
124+
expect([1, 2, 3]).toMatchInlineSnapshot(\`
125+
Array [
126+
1,
127+
2,
128+
3,
129+
]
130+
\`);
131+
});
132+
133+
`;
134+
121135
exports[`indentation is correct in the presences of existing snapshots: existing snapshot 1`] = `
122136
test('existing snapshot', () => {
123137
expect({hello: 'world'}).toMatchInlineSnapshot(\`

Diff for: e2e/__tests__/toMatchInlineSnapshot.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,20 @@ test('indentation is correct in the presences of existing snapshots', () => {
382382
expect(exitCode).toBe(0);
383383
expect(wrap(fileAfter)).toMatchSnapshot('existing snapshot');
384384
});
385+
386+
test('indentation is correct in the presences of existing snapshots, when the file is correctly formatted by prettier', () => {
387+
const filename = 'existing-snapshot.test.js';
388+
const test = `
389+
it('is true', () => {
390+
expect(true).toMatchInlineSnapshot(\`true\`);
391+
expect([1, 2, 3]).toMatchInlineSnapshot();
392+
});\\n
393+
`;
394+
395+
writeFiles(TESTS_DIR, {[filename]: test});
396+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
397+
const fileAfter = readFile(filename);
398+
expect(stderr).toMatch('1 snapshot written from 1 test suite.');
399+
expect(exitCode).toBe(0);
400+
expect(wrap(fileAfter)).toMatchSnapshot('existing snapshot');
401+
});

0 commit comments

Comments
 (0)