From 22f605fcb93fd80003a1739c878b48427b07a8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Thu, 5 Apr 2018 18:20:56 +0100 Subject: [PATCH] Updates snapshots --- integration-tests/Utils.js | 12 ++++++++++-- .../__tests__/__snapshots__/globals.test.js.snap | 8 ++++---- .../__snapshots__/show_config.test.js.snap | 6 ++++++ integration-tests/__tests__/globals.test.js | 5 ++--- .../jest-config/src/__tests__/normalize.test.js | 11 +++++------ packages/jest-config/src/normalize.js | 13 ++++--------- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/integration-tests/Utils.js b/integration-tests/Utils.js index 899145fafe6b..7f3fec5d6935 100644 --- a/integration-tests/Utils.js +++ b/integration-tests/Utils.js @@ -129,7 +129,11 @@ 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, ); @@ -147,11 +151,15 @@ const extractSummary = (stdout: string) => { .replace(/\d*\.?\d+m?s/g, '<>') .replace(/, estimated <>/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:<>:<>'); + } + return {rest, summary}; }; diff --git a/integration-tests/__tests__/__snapshots__/globals.test.js.snap b/integration-tests/__tests__/__snapshots__/globals.test.js.snap index 4dc71b817345..90e81f980f56 100644 --- a/integration-tests/__tests__/__snapshots__/globals.test.js.snap +++ b/integration-tests/__tests__/__snapshots__/globals.test.js.snap @@ -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:<>:<> + at __tests__/only-constructs.test.js:<>:<> " `; @@ -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:<>:<> + at __tests__/only-constructs.test.js:<>:<> " `; diff --git a/integration-tests/__tests__/__snapshots__/show_config.test.js.snap b/integration-tests/__tests__/__snapshots__/show_config.test.js.snap index 43a2c9b36c5e..22911ad113be 100644 --- a/integration-tests/__tests__/__snapshots__/show_config.test.js.snap +++ b/integration-tests/__tests__/__snapshots__/show_config.test.js.snap @@ -54,6 +54,12 @@ exports[`--showConfig outputs config info and exits 1`] = ` \\"testRunner\\": \\"<>/jest-jasmine2/build/index.js\\", \\"testURL\\": \\"about:blank\\", \\"timers\\": \\"real\\", + \\"transform\\": [ + [ + \\"^.+\\\\\\\\.jsx?$\\", + \\"<>/babel-jest/build/index.js\\" + ] + ], \\"transformIgnorePatterns\\": [ \\"/node_modules/\\" ], diff --git a/integration-tests/__tests__/globals.test.js b/integration-tests/__tests__/globals.test.js index 79cc76beaac8..22a8e60f6041 100644 --- a/integration-tests/__tests__/globals.test.js +++ b/integration-tests/__tests__/globals.test.js @@ -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(); }); @@ -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(); }); diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index b4a9c00487f6..718e24404c32 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -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, ); }); @@ -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' + diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index 7c85964f3b57..93b3ce7ae6cb 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -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'; @@ -103,7 +99,6 @@ const setupPreset = ( }; const setupBabelJest = (options: InitialOptions) => { - const basedir = options.rootDir; const transform = options.transform; let babelJest; if (transform) { @@ -113,11 +108,11 @@ 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; } @@ -125,7 +120,7 @@ const setupBabelJest = (options: InitialOptions) => { } else { babelJest = require.resolve('babel-jest'); options.transform = { - [DEFAULT_JS_PATTERN]: babelJest + [DEFAULT_JS_PATTERN]: babelJest, }; }