Skip to content

Commit

Permalink
snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Mar 3, 2019
1 parent ff480e0 commit 1ead0ff
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
41 changes: 41 additions & 0 deletions e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`warns if describe returns a Promise 1`] = `
" console.warn
● Test suite failed to run
Returning a Promise from \\"describe\\" is not supported. Tests must be defined synchronously.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
> 11 | describe('Promise describe warns', () => {
| ^
12 | it('t', () => {});
13 | return Promise.resolve();
14 | });
at Object.describe (__tests__/describeReturnPromise.test.js:11:1)
"
`;

exports[`warns if describe returns something 1`] = `
" console.warn
● Test suite failed to run
A \\"describe\\" callback must not return a value.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
> 11 | describe('describe return warns', () => {
| ^
12 | it('t', () => {});
13 | return 42;
14 | });
at Object.describe (__tests__/describeReturnSomething.test.js:11:1)
"
`;
17 changes: 7 additions & 10 deletions e2e/__tests__/declarationErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

import runJest from '../runJest';

const normalizeCircusJasmine = (str: string) =>
str
.replace(/console\.warn .+:\d+/, 'console.warn')
.replace(/.+addSpecsToSuite (.+:\d+:\d+).+\n/, '');

it('warns if describe returns a Promise', () => {
const result = runJest('declaration-errors', [
'describeReturnPromise.test.js',
]);

expect(result.status).toBe(0);
expect(result.stdout).toContain('Tests must be defined synchronously');
expect(result.stdout).toContain(
'at Object.describe (__tests__/describeReturnPromise.test.js',
);
expect(normalizeCircusJasmine(result.stdout)).toMatchSnapshot();
});

it('warns if describe returns something', () => {
Expand All @@ -25,10 +27,5 @@ it('warns if describe returns something', () => {
]);

expect(result.status).toBe(0);
expect(result.stdout).toContain(
'"describe" callback must not return a value',
);
expect(result.stdout).toContain(
'at Object.describe (__tests__/describeReturnSomething.test.js',
);
expect(normalizeCircusJasmine(result.stdout)).toMatchSnapshot();
});

0 comments on commit 1ead0ff

Please sign in to comment.