Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 19, 2022
1 parent 36b2c4d commit 7ed613b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
15 changes: 10 additions & 5 deletions e2e/__tests__/toMatchInlineSnapshotWithJSX.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
'<rootDir>',
),
).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: <rootDir>/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('<div>x</div>', () => {
Expand All @@ -43,10 +48,10 @@ it('successfully runs the tests inside `to-match-inline-snapshot-with-jsx/`', ()
14 | y
15 | </div>
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)
"
`);

Expand Down
20 changes: 20 additions & 0 deletions packages/jest-snapshot/src/__tests__/InlineSnapshots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ test('saveInlineSnapshots() replaces empty function call with a template literal
snapshot: '1',
},
],
dir,
'prettier',
);

Expand All @@ -81,6 +82,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`);
frame: {column: 11, file: filename, line} as Frame,
snapshot: '[1, 2]',
})),
dir,
null,
);

Expand Down Expand Up @@ -111,6 +113,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`);
frame: {column: 11, file: filename, line} as Frame,
snapshot: '[1, 2]',
})),
dir,
'bad-prettier',
);

Expand Down Expand Up @@ -143,6 +146,7 @@ expect(a).toMatchInlineSnapshot();
snapshot: "[{ foo: 'one' }, { foo: 'two' }]",
},
],
dir,
null,
);

Expand Down Expand Up @@ -177,6 +181,7 @@ it('foos', async () => {
snapshot: '<div>hello</div>',
},
],
dir,
null,
);

Expand Down Expand Up @@ -218,6 +223,7 @@ expect(a).toMatchInlineSnapshot();
snapshot: '<div>hello</div>',
},
],
dir,
null,
);

Expand Down Expand Up @@ -248,6 +254,7 @@ expect(a).toMatchInlineSnapshot(\`[1, 2]\`);
frame: {column: 11, file: filename, line} as Frame,
snapshot: '[1, 2]',
})),
dir,
'prettier',
);

Expand Down Expand Up @@ -275,6 +282,7 @@ test.each([['babel'], ['flow'], ['typescript']])(
snapshot: '1',
},
],
dir,
'prettier',
);

Expand All @@ -299,6 +307,7 @@ test('saveInlineSnapshots() replaces existing template literal with property mat
snapshot: '1',
},
],
dir,
'prettier',
);

Expand All @@ -320,6 +329,7 @@ test.each(['prettier', null])(
snapshot: '1',
},
],
dir,
prettierModule,
);

Expand All @@ -345,6 +355,7 @@ test('saveInlineSnapshots() throws if frame does not match', () => {
snapshot: '1',
},
],
dir,
'prettier',
);

Expand All @@ -362,6 +373,7 @@ test('saveInlineSnapshots() throws if multiple calls to to the same location', (
{frame, snapshot: '1'},
{frame, snapshot: '2'},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -397,6 +409,7 @@ test('saveInlineSnapshots() works with non-literals in expect call', () => {
snapshot: "{a: 'a'}",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -425,6 +438,7 @@ test('saveInlineSnapshots() indents multi-line snapshots with spaces', () => {
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -467,6 +481,7 @@ test('saveInlineSnapshots() does not re-indent error snapshots', () => {
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -516,6 +531,7 @@ test('saveInlineSnapshots() does not re-indent already indented snapshots', () =
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -558,6 +574,7 @@ test('saveInlineSnapshots() indents multi-line snapshots with tabs', () => {
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -590,6 +607,7 @@ test('saveInlineSnapshots() indents snapshots after prettier reformats', () => {
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -621,6 +639,7 @@ test('saveInlineSnapshots() does not indent empty lines', () => {
snapshot: '\nhello\n\nworld\n',
},
],
dir,
'prettier',
);

Expand Down Expand Up @@ -655,6 +674,7 @@ test('saveInlineSnapshots() indents awaited snapshots with spaces', () => {
snapshot: "\nObject {\n a: 'a'\n}\n",
},
],
dir,
'prettier',
);

Expand Down

0 comments on commit 7ed613b

Please sign in to comment.