Skip to content

Commit

Permalink
wrap to avoid quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Mar 28, 2020
1 parent b68f138 commit 012dbbc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
24 changes: 12 additions & 12 deletions e2e/__tests__/__snapshots__/wrongEnv.test.ts.snap
@@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Wrong globals for environment print useful error for document 1`] = `
"FAIL __tests__/node.js
FAIL __tests__/node.js
✕ use document
○ skipped use window
● use document
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
Consider using the \\"jsdom\\" test environment.
Consider using the "jsdom" test environment.
ReferenceError: document is not defined
Expand All @@ -20,17 +20,17 @@ exports[`Wrong globals for environment print useful error for document 1`] = `
18 | console.log(div);
19 |
at Object.document (__tests__/node.js:16:15)"
at Object.document (__tests__/node.js:16:15)
`;
exports[`Wrong globals for environment print useful error for unref 1`] = `
"FAIL __tests__/jsdom.js
FAIL __tests__/jsdom.js
use unref
use unref
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
Consider using the \\"node\\" test environment.
Consider using the "node" test environment.
TypeError: setTimeout(...).unref is not a function
Expand All @@ -42,18 +42,18 @@ exports[`Wrong globals for environment print useful error for unref 1`] = `
15 | expect(1).toBe(1);
16 | });
at Object.unref (__tests__/jsdom.js:13:27)"
at Object.unref (__tests__/jsdom.js:13:27)
`;
exports[`Wrong globals for environment print useful error for window 1`] = `
"FAIL __tests__/node.js
FAIL __tests__/node.js
use window
skipped use document
use window
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
Consider using the \\"jsdom\\" test environment.
Consider using the "jsdom" test environment.
ReferenceError: window is not defined
Expand All @@ -65,15 +65,15 @@ exports[`Wrong globals for environment print useful error for window 1`] = `
26 | console.log(location);
27 |
at Object.window (__tests__/node.js:24:20)"
at Object.window (__tests__/node.js:24:20)
`;
exports[`Wrong globals for environment print useful error when it explodes during evaluation 1`] = `
"FAIL __tests__/beforeTest.js
FAIL __tests__/beforeTest.js
Test suite failed to run
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/en/configuration#testenvironment-string.
Consider using the \\"jsdom\\" test environment.
Consider using the "jsdom" test environment.
ReferenceError: document is not defined
Expand All @@ -85,5 +85,5 @@ exports[`Wrong globals for environment print useful error when it explodes durin
15 | console.log(div);
16 |
at Object.document (__tests__/beforeTest.js:13:13)"
at Object.document (__tests__/beforeTest.js:13:13)
`;
23 changes: 11 additions & 12 deletions e2e/__tests__/wrongEnv.test.ts
Expand Up @@ -5,31 +5,30 @@
* LICENSE file in the root directory of this source tree.
*/

import wrap from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';
import {extractSummary} from '../Utils';

function assertFailuresAndSnapshot(args: Array<string>) {
const result = runJest('wrong-env', args);
expect(result.exitCode).toBe(1);
expect(wrap(extractSummary(result.stderr).rest)).toMatchSnapshot();
}

describe('Wrong globals for environment', () => {
it('print useful error for window', () => {
const result = runJest('wrong-env', ['node', '-t=window']);
expect(result.exitCode).toBe(1);
expect(extractSummary(result.stderr).rest).toMatchSnapshot();
assertFailuresAndSnapshot(['node', '-t=window']);
});

it('print useful error for document', () => {
const result = runJest('wrong-env', ['node', '-t=document']);
expect(result.exitCode).toBe(1);
expect(extractSummary(result.stderr).rest).toMatchSnapshot();
assertFailuresAndSnapshot(['node', '-t=document']);
});

it('print useful error for unref', () => {
const result = runJest('wrong-env', ['jsdom', '-t=unref']);
expect(result.exitCode).toBe(1);
expect(extractSummary(result.stderr).rest).toMatchSnapshot();
assertFailuresAndSnapshot(['jsdom', '-t=unref']);
});

it('print useful error when it explodes during evaluation', () => {
const result = runJest('wrong-env', ['beforeTest']);
expect(result.exitCode).toBe(1);
expect(extractSummary(result.stderr).rest).toMatchSnapshot();
assertFailuresAndSnapshot(['beforeTest']);
});
});

0 comments on commit 012dbbc

Please sign in to comment.