Skip to content

Commit

Permalink
Updates snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Apr 10, 2018
1 parent 169a91f commit 76adee3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
15 changes: 13 additions & 2 deletions integration-tests/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ const createEmptyPackage = (
);
};

const extractSummary = (stdout: string) => {
type ExtractSummaryOptions = {|
stripLocation: boolean,
|};

const extractSummary = (
stdout: string,
{stripLocation = false}: ExtractSummaryOptions = {},
) => {
const match = stdout.match(
/Test Suites:.*\nTests.*\nSnapshots.*\nTime.*(\nRan all test suites)*.*\n*$/gm,
);
Expand All @@ -147,11 +154,15 @@ const extractSummary = (stdout: string) => {
.replace(/\d*\.?\d+m?s/g, '<<REPLACED>>')
.replace(/, estimated <<REPLACED>>/g, '');

const rest = cleanupStackTrace(
let rest = cleanupStackTrace(
// remove all timestamps
stdout.slice(0, -match[0].length).replace(/\s*\(\d*\.?\d+m?s\)$/gm, ''),
);

if (stripLocation) {
rest = rest.replace(/(at .*):\d+:\d+/g, '$1:<<LINE>>:<<COLUMN>>');
}

return {rest, summary};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ exports[`cannot test with no implementation 1`] = `
4 | test('test, no implementation');
5 |
at packages/jest-jasmine2/build/jasmine/Env.js:429:15
at __tests__/only-constructs.test.js:3:5
at packages/jest-jasmine2/build/jasmine/Env.js:<<LINE>>:<<COLUMN>>
at __tests__/only-constructs.test.js:<<LINE>>:<<COLUMN>>
"
`;
Expand All @@ -59,8 +59,8 @@ exports[`cannot test with no implementation with expand arg 1`] = `
4 | test('test, no implementation');
5 |
at packages/jest-jasmine2/build/jasmine/Env.js:429:15
at __tests__/only-constructs.test.js:3:5
at packages/jest-jasmine2/build/jasmine/Env.js:<<LINE>>:<<COLUMN>>
at __tests__/only-constructs.test.js:<<LINE>>:<<COLUMN>>
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ exports[`--showConfig outputs config info and exits 1`] = `
\\"testRunner\\": \\"<<REPLACED_JEST_PACKAGES_DIR>>/jest-jasmine2/build/index.js\\",
\\"testURL\\": \\"about:blank\\",
\\"timers\\": \\"real\\",
\\"transform\\": [
[
\\"^.+\\\\\\\\.jsx?$\\",
\\"<<REPLACED_JEST_PACKAGES_DIR>>/babel-jest/build/index.js\\"
]
],
\\"transformIgnorePatterns\\": [
\\"/node_modules/\\"
],
Expand Down
5 changes: 2 additions & 3 deletions integration-tests/__tests__/globals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ test('cannot test with no implementation', () => {
const {stderr, status} = runJest(DIR);
expect(status).toBe(1);

const {summary, rest} = extractSummary(stderr);

const {summary, rest} = extractSummary(stderr, {stripLocation: true});
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
Expand Down Expand Up @@ -201,7 +200,7 @@ test('cannot test with no implementation with expand arg', () => {
const {stderr, status} = runJest(DIR, ['--expand']);
expect(status).toBe(1);

const {summary, rest} = extractSummary(stderr);
const {summary, rest} = extractSummary(stderr, {stripLocation: true});
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
Expand Down
11 changes: 5 additions & 6 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,10 @@ describe('babel-jest', () => {
beforeEach(() => {
Resolver = require('jest-resolve');
Resolver.findNodeModule = jest.fn(
name => {
return name.indexOf('babel-jest') === -1 ? path.sep + 'node_modules' + path.sep + name : name;
}
name =>
name.indexOf('babel-jest') === -1
? path.sep + 'node_modules' + path.sep + name
: name,
);
});

Expand All @@ -699,9 +700,7 @@ describe('babel-jest', () => {
);

expect(options.transform[0][0]).toBe(DEFAULT_JS_PATTERN);
expect(options.transform[0][1]).toEqual(
require.resolve('babel-jest'),
);
expect(options.transform[0][1]).toEqual(require.resolve('babel-jest'));
expect(options.setupFiles).toEqual([
path.sep +
'node_modules' +
Expand Down
13 changes: 4 additions & 9 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ import {
getTestEnvironment,
resolve,
} from './utils';
import {
NODE_MODULES,
DEFAULT_JS_PATTERN,
DEFAULT_REPORTER_LABEL,
} from './constants';
import {DEFAULT_JS_PATTERN, DEFAULT_REPORTER_LABEL} from './constants';
import {validateReporters} from './reporter_validation_errors';
import DEFAULT_CONFIG from './defaults';
import DEPRECATED_CONFIG from './deprecated';
Expand Down Expand Up @@ -103,7 +99,6 @@ const setupPreset = (
};

const setupBabelJest = (options: InitialOptions) => {
const basedir = options.rootDir;
const transform = options.transform;
let babelJest;
if (transform) {
Expand All @@ -113,19 +108,19 @@ const setupBabelJest = (options: InitialOptions) => {
});

if (customJSPattern) {
const customJSTransformer = options.transform[customJSPattern];
const customJSTransformer = transform[customJSPattern];

if (customJSTransformer === 'babel-jest') {
babelJest = require.resolve('babel-jest');
options.transform[customJSPattern] = babelJest;
transform[customJSPattern] = babelJest;
} else if (customJSTransformer.includes('babel-jest')) {
babelJest = customJSTransformer;
}
}
} else {
babelJest = require.resolve('babel-jest');
options.transform = {
[DEFAULT_JS_PATTERN]: babelJest
[DEFAULT_JS_PATTERN]: babelJest,
};
}

Expand Down

0 comments on commit 76adee3

Please sign in to comment.