diff --git a/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap b/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap index a64fb6a82fde..4fbfd82ce35a 100644 --- a/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap +++ b/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap @@ -118,6 +118,20 @@ test('handles property matchers', () => { `; +exports[`indentation is correct in the presences of existing snapshots, when the file is correctly formatted by prettier: existing snapshot 1`] = ` +it('is true', () => { + expect(true).toMatchInlineSnapshot(\`true\`); + expect([1, 2, 3]).toMatchInlineSnapshot(\` + Array [ + 1, + 2, + 3, + ] + \`); +}); + +`; + exports[`indentation is correct in the presences of existing snapshots: existing snapshot 1`] = ` test('existing snapshot', () => { expect({hello: 'world'}).toMatchInlineSnapshot(\` diff --git a/e2e/__tests__/toMatchInlineSnapshot.test.ts b/e2e/__tests__/toMatchInlineSnapshot.test.ts index 228662fe6e57..4ac3db884836 100644 --- a/e2e/__tests__/toMatchInlineSnapshot.test.ts +++ b/e2e/__tests__/toMatchInlineSnapshot.test.ts @@ -382,3 +382,20 @@ test('indentation is correct in the presences of existing snapshots', () => { expect(exitCode).toBe(0); expect(wrap(fileAfter)).toMatchSnapshot('existing snapshot'); }); + +test('indentation is correct in the presences of existing snapshots, when the file is correctly formatted by prettier', () => { + const filename = 'existing-snapshot.test.js'; + const test = ` + it('is true', () => { + expect(true).toMatchInlineSnapshot(\`true\`); + expect([1, 2, 3]).toMatchInlineSnapshot(); + });\\n + `; + + writeFiles(TESTS_DIR, {[filename]: test}); + const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]); + const fileAfter = readFile(filename); + expect(stderr).toMatch('1 snapshot written from 1 test suite.'); + expect(exitCode).toBe(0); + expect(wrap(fileAfter)).toMatchSnapshot('existing snapshot'); +});