From 7ed613b5926ce3ad0c0fa779bc926ae0ee1406db Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 19 Aug 2022 12:53:02 +0200 Subject: [PATCH] update tests --- .../toMatchInlineSnapshotWithJSX.test.ts | 15 +++++++++----- .../src/__tests__/InlineSnapshots.test.ts | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/e2e/__tests__/toMatchInlineSnapshotWithJSX.test.ts b/e2e/__tests__/toMatchInlineSnapshotWithJSX.test.ts index adf288f69706..41355a03ccc2 100644 --- a/e2e/__tests__/toMatchInlineSnapshotWithJSX.test.ts +++ b/e2e/__tests__/toMatchInlineSnapshotWithJSX.test.ts @@ -30,10 +30,15 @@ afterAll(() => { it('successfully runs the tests inside `to-match-inline-snapshot-with-jsx/`', () => { const updateSnapshotRun = runWithJson(DIR, ['--updateSnapshot']); - expect(updateSnapshotRun.json.testResults[0].message).toMatchInlineSnapshot(` + expect( + updateSnapshotRun.json.testResults[0].message.replace( + process.cwd(), + '', + ), + ).toMatchInlineSnapshot(` " ● Test suite failed to run - SyntaxError: /home/eps1lon/Development/forks/jest/e2e/to-match-inline-snapshot-with-jsx/__tests__/MismatchingSnapshot.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (12:26): + SyntaxError: /e2e/to-match-inline-snapshot-with-jsx/__tests__/MismatchingSnapshot.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (12:26): 10 | 11 | test('
x
', () => { @@ -43,10 +48,10 @@ it('successfully runs the tests inside `to-match-inline-snapshot-with-jsx/`', () 14 | y 15 | - Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation. - If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing. + Add @babel/preset-react (https://github.com/babel/babel/tree/main/packages/babel-preset-react) to the 'presets' section of your Babel config to enable transformation. + If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx) to the 'plugins' section to enable parsing. - at instantiate (../../node_modules/@babel/parser/src/parse-error/credentials.js:61:22) + at instantiate (../../node_modules/@babel/parser/src/parse-error/credentials.ts:62:21) " `); diff --git a/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts b/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts index a1c275177865..5a668424a823 100644 --- a/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts +++ b/packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts @@ -55,6 +55,7 @@ test('saveInlineSnapshots() replaces empty function call with a template literal snapshot: '1', }, ], + dir, 'prettier', ); @@ -81,6 +82,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`); frame: {column: 11, file: filename, line} as Frame, snapshot: '[1, 2]', })), + dir, null, ); @@ -111,6 +113,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`); frame: {column: 11, file: filename, line} as Frame, snapshot: '[1, 2]', })), + dir, 'bad-prettier', ); @@ -143,6 +146,7 @@ expect(a).toMatchInlineSnapshot(); snapshot: "[{ foo: 'one' }, { foo: 'two' }]", }, ], + dir, null, ); @@ -177,6 +181,7 @@ it('foos', async () => { snapshot: '
hello
', }, ], + dir, null, ); @@ -218,6 +223,7 @@ expect(a).toMatchInlineSnapshot(); snapshot: '
hello
', }, ], + dir, null, ); @@ -248,6 +254,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`); frame: {column: 11, file: filename, line} as Frame, snapshot: '[1, 2]', })), + dir, 'prettier', ); @@ -275,6 +282,7 @@ test.each([['babel'], ['flow'], ['typescript']])( snapshot: '1', }, ], + dir, 'prettier', ); @@ -299,6 +307,7 @@ test('saveInlineSnapshots() replaces existing template literal with property mat snapshot: '1', }, ], + dir, 'prettier', ); @@ -320,6 +329,7 @@ test.each(['prettier', null])( snapshot: '1', }, ], + dir, prettierModule, ); @@ -345,6 +355,7 @@ test('saveInlineSnapshots() throws if frame does not match', () => { snapshot: '1', }, ], + dir, 'prettier', ); @@ -362,6 +373,7 @@ test('saveInlineSnapshots() throws if multiple calls to to the same location', ( {frame, snapshot: '1'}, {frame, snapshot: '2'}, ], + dir, 'prettier', ); @@ -397,6 +409,7 @@ test('saveInlineSnapshots() works with non-literals in expect call', () => { snapshot: "{a: 'a'}", }, ], + dir, 'prettier', ); @@ -425,6 +438,7 @@ test('saveInlineSnapshots() indents multi-line snapshots with spaces', () => { snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', ); @@ -467,6 +481,7 @@ test('saveInlineSnapshots() does not re-indent error snapshots', () => { snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', ); @@ -516,6 +531,7 @@ test('saveInlineSnapshots() does not re-indent already indented snapshots', () = snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', ); @@ -558,6 +574,7 @@ test('saveInlineSnapshots() indents multi-line snapshots with tabs', () => { snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', ); @@ -590,6 +607,7 @@ test('saveInlineSnapshots() indents snapshots after prettier reformats', () => { snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', ); @@ -621,6 +639,7 @@ test('saveInlineSnapshots() does not indent empty lines', () => { snapshot: '\nhello\n\nworld\n', }, ], + dir, 'prettier', ); @@ -655,6 +674,7 @@ test('saveInlineSnapshots() indents awaited snapshots with spaces', () => { snapshot: "\nObject {\n a: 'a'\n}\n", }, ], + dir, 'prettier', );