From 77eaa1fcaa72b8bd3bbdea666db80bed12c1e52c Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 27 May 2021 23:03:49 +0200 Subject: [PATCH 1/5] add missing slash dependency to circus --- CHANGELOG.md | 1 + packages/jest-circus/package.json | 1 + yarn.lock | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36888f1eb302..8b2454ee0ce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes +- `[jest-circus]` Add missing `slash` dependency ([#11465](https://github.com/facebook/jest/pull/11465)) - `[jest-circus, @jest/test-sequencer]` Remove dependency on `jest-runner` ([#11466](https://github.com/facebook/jest/pull/11466)) - `[jest-runner]` Remove dependency on `jest-config` ([#11466](https://github.com/facebook/jest/pull/11466)) - `[jest-worker]` Loosen engine requirement to `>= 10.13.0` ([#11451](https://github.com/facebook/jest/pull/11451)) diff --git a/packages/jest-circus/package.json b/packages/jest-circus/package.json index 328e023f1b2f..06016431ba90 100644 --- a/packages/jest-circus/package.json +++ b/packages/jest-circus/package.json @@ -31,6 +31,7 @@ "jest-snapshot": "^27.0.1", "jest-util": "^27.0.1", "pretty-format": "^27.0.1", + "slash": "^3.0.0", "stack-utils": "^2.0.3", "throat": "^6.0.1" }, diff --git a/yarn.lock b/yarn.lock index 09304724cd7d..905302240d27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13266,6 +13266,7 @@ fsevents@^1.2.7: jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^27.0.1 pretty-format: ^27.0.1 + slash: ^3.0.0 stack-utils: ^2.0.3 throat: ^6.0.1 languageName: unknown From f9e8e2a3f0e5a1056d25914febc3fd3d36933668 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 27 May 2021 23:04:04 +0200 Subject: [PATCH 2/5] resolve `runner` to absolute path in `normalize` --- CHANGELOG.md | 1 + packages/jest-config/package.json | 1 + packages/jest-config/src/__tests__/normalize.test.ts | 2 +- packages/jest-config/src/normalize.ts | 4 ++++ packages/jest-config/tsconfig.json | 1 + packages/jest-core/src/__tests__/runJest.test.js | 5 ++++- packages/jest-runner/src/runTest.ts | 4 +++- packages/jest-types/src/Config.ts | 2 +- packages/jest-util/src/requireOrImportModule.ts | 6 ++++-- yarn.lock | 1 + 10 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b2454ee0ce2..f2fcccb4c77d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - `[jest-circus]` Add missing `slash` dependency ([#11465](https://github.com/facebook/jest/pull/11465)) - `[jest-circus, @jest/test-sequencer]` Remove dependency on `jest-runner` ([#11466](https://github.com/facebook/jest/pull/11466)) +- `[jest-config]` Resolve `config.runner` to absolute path ([#11465](https://github.com/facebook/jest/pull/11465)) - `[jest-runner]` Remove dependency on `jest-config` ([#11466](https://github.com/facebook/jest/pull/11466)) - `[jest-worker]` Loosen engine requirement to `>= 10.13.0` ([#11451](https://github.com/facebook/jest/pull/11451)) diff --git a/packages/jest-config/package.json b/packages/jest-config/package.json index 329b5d01924f..641f383fcf24 100644 --- a/packages/jest-config/package.json +++ b/packages/jest-config/package.json @@ -38,6 +38,7 @@ "jest-jasmine2": "^27.0.1", "jest-regex-util": "^27.0.1", "jest-resolve": "^27.0.1", + "jest-runner": "^27.0.1", "jest-util": "^27.0.1", "jest-validate": "^27.0.1", "micromatch": "^4.0.4", diff --git a/packages/jest-config/src/__tests__/normalize.test.ts b/packages/jest-config/src/__tests__/normalize.test.ts index 751c0cabe7dc..3a29e19d6337 100644 --- a/packages/jest-config/src/__tests__/normalize.test.ts +++ b/packages/jest-config/src/__tests__/normalize.test.ts @@ -1401,7 +1401,7 @@ describe('runner', () => { it('defaults to `jest-runner`', async () => { const {options} = await normalize({rootDir: '/root'}, {} as Config.Argv); - expect(options.runner).toBe('jest-runner'); + expect(options.runner).toBe(require.resolve('jest-runner')); }); it('resolves to runners that do not have the prefix', async () => { diff --git a/packages/jest-config/src/normalize.ts b/packages/jest-config/src/normalize.ts index a703f7f7a179..c13e0d3b4d40 100644 --- a/packages/jest-config/src/normalize.ts +++ b/packages/jest-config/src/normalize.ts @@ -1058,6 +1058,10 @@ export default async function normalize( rootDir: options.rootDir, }); + if (newOptions.runner === DEFAULT_CONFIG.runner) { + newOptions.runner = require.resolve(newOptions.runner); + } + newOptions.nonFlagArgs = argv._?.map(arg => `${arg}`); newOptions.testPathPattern = buildTestPathPattern(argv); newOptions.json = !!argv.json; diff --git a/packages/jest-config/tsconfig.json b/packages/jest-config/tsconfig.json index 7c9dc85e0510..4ffd33734047 100644 --- a/packages/jest-config/tsconfig.json +++ b/packages/jest-config/tsconfig.json @@ -13,6 +13,7 @@ {"path": "../jest-get-type"}, {"path": "../jest-regex-util"}, {"path": "../jest-resolve"}, + {"path": "../jest-runner"}, {"path": "../jest-types"}, {"path": "../jest-util"}, {"path": "../jest-validate"}, diff --git a/packages/jest-core/src/__tests__/runJest.test.js b/packages/jest-core/src/__tests__/runJest.test.js index 842407438f0c..daa74b5ac499 100644 --- a/packages/jest-core/src/__tests__/runJest.test.js +++ b/packages/jest-core/src/__tests__/runJest.test.js @@ -21,7 +21,10 @@ describe('runJest', () => { await runJest({ changedFilesPromise: Promise.resolve({repos: {git: {size: 0}}}), contexts: [], - globalConfig: {testSequencer: '@jest/test-sequencer', watch: true}, + globalConfig: { + testSequencer: require.resolve('@jest/test-sequencer'), + watch: true, + }, onComplete: () => null, outputStream: {}, startRun: {}, diff --git a/packages/jest-runner/src/runTest.ts b/packages/jest-runner/src/runTest.ts index b661248b94ee..23825859b0b9 100644 --- a/packages/jest-runner/src/runTest.ts +++ b/packages/jest-runner/src/runTest.ts @@ -109,7 +109,9 @@ async function runTestInternal( await transformer.requireAndTranspileModule(testEnvironment); const testFramework: TestFramework = await transformer.requireAndTranspileModule( - process.env.JEST_JASMINE === '1' ? 'jest-jasmine2' : config.testRunner, + process.env.JEST_JASMINE === '1' + ? require.resolve('jest-jasmine2') + : config.testRunner, ); const Runtime: typeof RuntimeClass = interopRequireDefault( config.moduleLoader diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index a2ffd2773c0c..68eaa4124a01 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -98,7 +98,7 @@ export type DefaultOptions = { restoreMocks: boolean; roots: Array; runTestsByPath: boolean; - runner: 'jest-runner'; + runner: string; setupFiles: Array; setupFilesAfterEnv: Array; skipFilter: boolean; diff --git a/packages/jest-util/src/requireOrImportModule.ts b/packages/jest-util/src/requireOrImportModule.ts index 9966ee727ba9..a2709f0a8aee 100644 --- a/packages/jest-util/src/requireOrImportModule.ts +++ b/packages/jest-util/src/requireOrImportModule.ts @@ -14,8 +14,10 @@ export default async function requireOrImportModule( filePath: Config.Path, applyInteropRequireDefault = true, ): Promise { - if (!isAbsolute(filePath) && filePath[0] === '.') { - throw new Error(`Jest: requireOrImportModule path must be absolute`); + if (!isAbsolute(filePath)) { + throw new Error( + `Jest: requireOrImportModule path must be absolute, was "${filePath}"`, + ); } try { const requiredModule = require(filePath); diff --git a/yarn.lock b/yarn.lock index 905302240d27..3c48f95e3958 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13328,6 +13328,7 @@ fsevents@^1.2.7: jest-jasmine2: ^27.0.1 jest-regex-util: ^27.0.1 jest-resolve: ^27.0.1 + jest-runner: ^27.0.1 jest-snapshot-serializer-raw: ^1.1.0 jest-util: ^27.0.1 jest-validate: ^27.0.1 From 99c1122bc2b60d7dd21592746be4e4667a8542d0 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 28 May 2021 00:34:12 +0200 Subject: [PATCH 3/5] fix almost all tests --- .../__snapshots__/showConfig.test.ts.snap | 2 +- .../src/__tests__/TestScheduler.test.js | 28 +- .../src/__tests__/ScriptTransformer.test.ts | 395 +++++++++++------- .../ScriptTransformer.test.ts.snap | 16 +- 4 files changed, 280 insertions(+), 161 deletions(-) diff --git a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap index d8af652bf08d..4ca4895bad34 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap @@ -48,7 +48,7 @@ exports[`--showConfig outputs config info and exits 1`] = ` "roots": [ "<>" ], - "runner": "jest-runner", + "runner": "<>/jest-runner/build/index.js", "setupFiles": [], "setupFilesAfterEnv": [], "skipFilter": false, diff --git a/packages/jest-core/src/__tests__/TestScheduler.test.js b/packages/jest-core/src/__tests__/TestScheduler.test.js index b707ef3289c9..7b6f4e54dbba 100644 --- a/packages/jest-core/src/__tests__/TestScheduler.test.js +++ b/packages/jest-core/src/__tests__/TestScheduler.test.js @@ -16,16 +16,20 @@ const mockSerialRunner = { isSerial: true, runTests: jest.fn(), }; -jest.mock('jest-runner-serial', () => jest.fn(() => mockSerialRunner), { - virtual: true, -}); +jest.mock( + `${__dirname}/jest-runner-serial`, + () => jest.fn(() => mockSerialRunner), + {virtual: true}, +); const mockParallelRunner = { runTests: jest.fn(), }; -jest.mock('jest-runner-parallel', () => jest.fn(() => mockParallelRunner), { - virtual: true, -}); +jest.mock( + `${__dirname}/jest-runner-parallel`, + () => jest.fn(() => mockParallelRunner), + {virtual: true}, +); const spyShouldRunInBand = jest.spyOn(testSchedulerHelper, 'shouldRunInBand'); @@ -89,7 +93,7 @@ test('schedule tests run in parallel per default', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: 'jest-runner-parallel', + runner: `${__dirname}/jest-runner-parallel`, transform: [], }), hasteFS: { @@ -112,7 +116,7 @@ test('schedule tests run in serial if the runner flags them', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: 'jest-runner-serial', + runner: `${__dirname}/jest-runner-serial`, transform: [], }), hasteFS: { @@ -136,7 +140,7 @@ test('should bail after `n` failures', async () => { config: makeProjectConfig({ moduleFileExtensions: ['.js'], rootDir: './', - runner: 'jest-runner-serial', + runner: `${__dirname}/jest-runner-serial`, transform: [], }), hasteFS: { @@ -168,7 +172,7 @@ test('should not bail if less than `n` failures', async () => { config: makeProjectConfig({ moduleFileExtensions: ['.js'], rootDir: './', - runner: 'jest-runner-serial', + runner: `${__dirname}/jest-runner-serial`, transform: [], }), hasteFS: { @@ -199,7 +203,7 @@ test('should set runInBand to run in serial', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: 'jest-runner-parallel', + runner: `${__dirname}/jest-runner-parallel`, transform: [], }), hasteFS: { @@ -225,7 +229,7 @@ test('should set runInBand to not run in serial', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: 'jest-runner-parallel', + runner: `${__dirname}/jest-runner-parallel`, transform: [], }), hasteFS: { diff --git a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts index 94ade78a4a2c..15512d12cef0 100644 --- a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts +++ b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts @@ -52,9 +52,10 @@ jest .mock('path', () => jest.requireActual('path').posix); jest.mock( - 'test_preprocessor', + `${__dirname}/test_preprocessor`, () => { - const escapeStrings = (str: string) => str.replace(/'/, `'`); + const escapeStrings = (str: string) => + str.replace(/'/, `'`).replace(new RegExp(__dirname, 'g'), ''); const transformer: Transformer = { getCacheKey: jest.fn(() => 'ab'), @@ -73,9 +74,10 @@ jest.mock( ); jest.mock( - 'test_async_preprocessor', + `${__dirname}/test_async_preprocessor`, () => { - const escapeStrings = (str: string) => str.replace(/'/, `'`); + const escapeStrings = (str: string) => + str.replace(/'/, `'`).replace(new RegExp(__dirname, 'g'), ''); const transformer: Transformer = { getCacheKeyAsync: jest.fn().mockResolvedValue('ab'), @@ -95,7 +97,7 @@ jest.mock( ); jest.mock( - 'configureable-preprocessor', + `${__dirname}/configureable-preprocessor`, () => ({ createTransformer: jest.fn(() => ({ process: jest.fn(() => 'processedCode'), @@ -105,7 +107,7 @@ jest.mock( ); jest.mock( - 'cache_fs_preprocessor', + `${__dirname}/cache_fs_preprocessor`, () => ({ getCacheKey: jest.fn(() => 'ab'), process: jest.fn(() => 'processedCode'), @@ -114,7 +116,7 @@ jest.mock( ); jest.mock( - 'cache_fs_async_preprocessor', + `${__dirname}/cache_fs_async_preprocessor`, () => ({ getCacheKeyAsync: jest.fn().mockResolvedValue('ab'), processAsync: jest.fn().mockResolvedValue('processedCode'), @@ -123,7 +125,7 @@ jest.mock( ); jest.mock( - 'preprocessor-with-sourcemaps', + `${__dirname}/preprocessor-with-sourcemaps`, () => ({ getCacheKey: jest.fn(() => 'ab'), process: jest.fn(), @@ -132,7 +134,7 @@ jest.mock( ); jest.mock( - 'async-preprocessor-with-sourcemaps', + `${__dirname}/async-preprocessor-with-sourcemaps`, () => ({ getCacheKeyAsync: jest.fn(() => 'ab'), processAsync: jest.fn(), @@ -141,7 +143,7 @@ jest.mock( ); jest.mock( - 'css-preprocessor', + `${__dirname}/css-preprocessor`, () => { const transformer: Transformer = { getCacheKey: jest.fn(() => 'cd'), @@ -158,30 +160,34 @@ jest.mock( {virtual: true}, ); -jest.mock('passthrough-preprocessor', () => ({process: jest.fn()}), { - virtual: true, -}); +jest.mock( + `${__dirname}/passthrough-preprocessor`, + () => ({process: jest.fn()}), + {virtual: true}, +); // Bad preprocessor -jest.mock('skipped-required-props-preprocessor', () => ({}), {virtual: true}); +jest.mock(`${__dirname}/skipped-required-props-preprocessor`, () => ({}), { + virtual: true, +}); // Bad preprocessor jest.mock( - 'skipped-required-props-preprocessor-only-sync', + `${__dirname}/skipped-required-props-preprocessor-only-sync`, () => ({process: () => ''}), {virtual: true}, ); // Bad preprocessor jest.mock( - 'skipped-required-props-preprocessor-only-async', + `${__dirname}/skipped-required-props-preprocessor-only-async`, () => ({processAsync: async () => ''}), {virtual: true}, ); // Bad preprocessor jest.mock( - 'skipped-required-create-transformer-props-preprocessor', + `${__dirname}/skipped-required-create-transformer-props-preprocessor`, () => ({ createTransformer() { return {}; @@ -191,7 +197,7 @@ jest.mock( ); jest.mock( - 'skipped-process-method-preprocessor', + `${__dirname}/skipped-process-method-preprocessor`, () => ({ createTransformer() { return {process: jest.fn(() => 'code')}; @@ -201,7 +207,7 @@ jest.mock( ); jest.mock( - 'factory-for-async-preprocessor', + `${__dirname}/factory-for-async-preprocessor`, () => ({ createTransformer() { return {processAsync: jest.fn().mockResolvedValue('code')}; @@ -400,7 +406,7 @@ describe('ScriptTransformer', () => { it("throws an error if `process` doesn't return a string or an object containing `code` key with processed string", async () => { config = { ...config, - transform: [['\\.js$', 'passthrough-preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/passthrough-preprocessor`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -412,7 +418,9 @@ describe('ScriptTransformer', () => { incorrectReturnValues.forEach(([returnValue, filePath]) => { invariant(typeof filePath === 'string'); - require('passthrough-preprocessor').process.mockReturnValue(returnValue); + require(`${__dirname}/passthrough-preprocessor`).process.mockReturnValue( + returnValue, + ); expect(() => scriptTransformer.transform(filePath, getCoverageOptions()), ).toThrow('must return a string'); @@ -425,7 +433,9 @@ describe('ScriptTransformer', () => { correctReturnValues.forEach(([returnValue, filePath]) => { invariant(typeof filePath === 'string'); - require('passthrough-preprocessor').process.mockReturnValue(returnValue); + require(`${__dirname}/passthrough-preprocessor`).process.mockReturnValue( + returnValue, + ); expect(() => scriptTransformer.transform(filePath, getCoverageOptions()), ).not.toThrow(); @@ -445,7 +455,7 @@ describe('ScriptTransformer', () => { ]; const buildPromise = async ([returnValue, filePath]): Promise => { - const processorName = `passthrough-preprocessor${filePath.replace( + const processorName = `${__dirname}/passthrough-preprocessor${filePath.replace( /\.|\//g, '-', )}`; @@ -489,7 +499,9 @@ describe('ScriptTransformer', () => { it('throws an error if neither `process` nor `processAsync is defined', async () => { config = { ...config, - transform: [['\\.js$', 'skipped-required-props-preprocessor', {}]], + transform: [ + ['\\.js$', `${__dirname}/skipped-required-props-preprocessor`, {}], + ], }; await expect(() => createScriptTransformer(config)).rejects.toThrow( 'Jest: a transform must export a `process` or `processAsync` function.', @@ -500,14 +512,18 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', 'skipped-required-props-preprocessor-only-async', {}], + [ + '\\.js$', + `${__dirname}/skipped-required-props-preprocessor-only-async`, + {}, + ], ], }; const scriptTransformer = await createScriptTransformer(config); expect(() => scriptTransformer.transformSource('sample.js', '', {instrument: false}), ).toThrow( - 'Jest: synchronous transformer skipped-required-props-preprocessor-only-async must export a "process" function.', + `Jest: synchronous transformer ${__dirname}/skipped-required-props-preprocessor-only-async must export a "process" function.`, ); }); @@ -515,7 +531,11 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', 'skipped-required-props-preprocessor-only-sync', {}], + [ + '\\.js$', + `${__dirname}/skipped-required-props-preprocessor-only-sync`, + {}, + ], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -532,7 +552,7 @@ describe('ScriptTransformer', () => { transform: [ [ '\\.js$', - 'skipped-required-create-transformer-props-preprocessor', + `${__dirname}/skipped-required-create-transformer-props-preprocessor`, {}, ], ], @@ -545,7 +565,9 @@ describe('ScriptTransformer', () => { it("shouldn't throw error without process method. But with correct createTransformer method", async () => { config = { ...config, - transform: [['\\.js$', 'skipped-process-method-preprocessor', {}]], + transform: [ + ['\\.js$', `${__dirname}/skipped-process-method-preprocessor`, {}], + ], }; const scriptTransformer = await createScriptTransformer(config); expect(() => @@ -557,8 +579,12 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['async-sample.js', 'factory-for-async-preprocessor', {}], - ['sync-sample.js', 'skipped-process-method-preprocessor', {}], + ['async-sample.js', `${__dirname}/factory-for-async-preprocessor`, {}], + [ + 'sync-sample.js', + `${__dirname}/skipped-process-method-preprocessor`, + {}, + ], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -577,14 +603,17 @@ describe('ScriptTransformer', () => { }); it('uses the supplied preprocessor', async () => { - config = {...config, transform: [['\\.js$', 'test_preprocessor', {}]]}; + config = { + ...config, + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + }; const scriptTransformer = await createScriptTransformer(config); const res1 = scriptTransformer.transform( '/fruits/banana.js', getCoverageOptions(), ); - expect(require('test_preprocessor').getCacheKey).toBeCalled(); + expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -597,14 +626,17 @@ describe('ScriptTransformer', () => { }); it('in async mode, uses the supplied preprocessor', async () => { - config = {...config, transform: [['\\.js$', 'test_preprocessor', {}]]}; + config = { + ...config, + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + }; const scriptTransformer = await createScriptTransformer(config); const res1 = await scriptTransformer.transformAsync( '/fruits/banana.js', getCoverageOptions(), ); - expect(require('test_preprocessor').getCacheKey).toBeCalled(); + expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -619,7 +651,7 @@ describe('ScriptTransformer', () => { it('in async mode, uses the supplied async preprocessor', async () => { config = { ...config, - transform: [['\\.js$', 'test_async_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], }; const scriptTransformer = await createScriptTransformer(config); const res1 = await scriptTransformer.transformAsync( @@ -627,7 +659,9 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect(require('test_async_preprocessor').getCacheKeyAsync).toBeCalled(); + expect( + require(`${__dirname}/test_async_preprocessor`).getCacheKeyAsync, + ).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -643,8 +677,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', 'test_preprocessor', {}], - ['\\.css$', 'css-preprocessor', {}], + ['\\.js$', `${__dirname}/test_preprocessor`, {}], + ['\\.css$', `${__dirname}/css-preprocessor`, {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -658,8 +692,8 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect(require('test_preprocessor').getCacheKey).toBeCalled(); - expect(require('css-preprocessor').getCacheKey).toBeCalled(); + expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); + expect(require(`${__dirname}/css-preprocessor`).getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); expect(wrap(res2.code)).toMatchSnapshot(); @@ -675,8 +709,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', 'test_async_preprocessor', {}], - ['\\.css$', 'css-preprocessor', {}], + ['\\.js$', `${__dirname}/test_async_preprocessor`, {}], + ['\\.css$', `${__dirname}/css-preprocessor`, {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -690,8 +724,10 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect(require('test_async_preprocessor').getCacheKeyAsync).toBeCalled(); - expect(require('css-preprocessor').getCacheKey).toBeCalled(); + expect( + require(`${__dirname}/test_async_preprocessor`).getCacheKeyAsync, + ).toBeCalled(); + expect(require(`${__dirname}/css-preprocessor`).getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); expect(wrap(res2.code)).toMatchSnapshot(); @@ -706,7 +742,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor supplies it', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -715,10 +751,12 @@ describe('ScriptTransformer', () => { version: 3, }; - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map, + }, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -736,7 +774,7 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if preprocessor supplies it', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -745,10 +783,12 @@ describe('ScriptTransformer', () => { version: 3, }; - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map, + }, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -766,7 +806,9 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if async preprocessor supplies it', async () => { config = { ...config, - transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], + transform: [ + ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], + ], }; const scriptTransformer = await createScriptTransformer(config); @@ -775,7 +817,7 @@ describe('ScriptTransformer', () => { version: 3, }; - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( { code: 'content', map, @@ -798,7 +840,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor inlines it', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -812,7 +854,9 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require('preprocessor-with-sourcemaps').process.mockReturnValue(content); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + content, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -830,7 +874,7 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if preprocessor inlines it', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -844,7 +888,9 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require('preprocessor-with-sourcemaps').process.mockReturnValue(content); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + content, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -862,7 +908,9 @@ describe('ScriptTransformer', () => { it('writes source map if async preprocessor inlines it', async () => { config = { ...config, - transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], + transform: [ + ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], + ], }; const scriptTransformer = await createScriptTransformer(config); @@ -876,7 +924,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( content, ); @@ -899,7 +947,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -914,7 +962,9 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require('preprocessor-with-sourcemaps').process.mockReturnValue(content); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + content, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -924,7 +974,14 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); + expect( + wrap( + console.warn.mock.calls[0][0].replace( + new RegExp(__dirname, 'g'), + '', + ), + ), + ).toMatchSnapshot(); console.warn = warn; }); @@ -934,7 +991,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -949,7 +1006,9 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require('preprocessor-with-sourcemaps').process.mockReturnValue(content); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + content, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -959,7 +1018,14 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); + expect( + wrap( + console.warn.mock.calls[0][0].replace( + new RegExp(__dirname, 'g'), + '', + ), + ), + ).toMatchSnapshot(); console.warn = warn; }); @@ -969,7 +1035,9 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], + transform: [ + ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], + ], }; const scriptTransformer = await createScriptTransformer(config); @@ -984,7 +1052,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( content, ); @@ -996,7 +1064,14 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); + expect( + wrap( + console.warn.mock.calls[0][0].replace( + new RegExp(__dirname, 'g'), + '', + ), + ), + ).toMatchSnapshot(); console.warn = warn; }); @@ -1004,7 +1079,7 @@ describe('ScriptTransformer', () => { it('writes source maps if given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1013,10 +1088,12 @@ describe('ScriptTransformer', () => { version: 3, }; - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map, + }, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1037,14 +1114,16 @@ describe('ScriptTransformer', () => { it('does not write source map if not given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map: null, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map: null, + }, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1057,14 +1136,16 @@ describe('ScriptTransformer', () => { it('in async mode, does not write source map if not given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(config); - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map: null, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map: null, + }, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1077,11 +1158,13 @@ describe('ScriptTransformer', () => { it('does not write source map if not given by the async preprocessor', async () => { config = { ...config, - transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], + transform: [ + ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], + ], }; const scriptTransformer = await createScriptTransformer(config); - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( { code: 'content', map: null, @@ -1099,7 +1182,7 @@ describe('ScriptTransformer', () => { it('should write a source map for the instrumented file when transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1120,10 +1203,12 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map, + }, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1144,7 +1229,7 @@ describe('ScriptTransformer', () => { it('in async mode, should write a source map for the instrumented file when transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], + transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1165,10 +1250,12 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map, + }, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1189,7 +1276,9 @@ describe('ScriptTransformer', () => { it('should write a source map for the instrumented file when async transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], + transform: [ + ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], + ], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1210,7 +1299,7 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( { code: 'content', map, @@ -1248,10 +1337,12 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map: null, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map: null, + }, + ); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1284,10 +1375,12 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('preprocessor-with-sourcemaps').process.mockReturnValue({ - code: 'content', - map: null, - }); + require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( + { + code: 'content', + map: null, + }, + ); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1320,7 +1413,7 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( + require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( { code: 'content', map: null, @@ -1346,7 +1439,13 @@ describe('ScriptTransformer', () => { it('passes expected transform options to getCacheKey', async () => { config = { ...config, - transform: [['\\.js$', 'test_preprocessor', {configKey: 'configValue'}]], + transform: [ + [ + '\\.js$', + `${__dirname}/test_preprocessor`, + {configKey: 'configValue'}, + ], + ], }; const scriptTransformer = await createScriptTransformer(config); @@ -1355,14 +1454,20 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKey} = require('test_preprocessor'); + const {getCacheKey} = require(`${__dirname}/test_preprocessor`); expect(getCacheKey).toMatchSnapshot(); }); it('in async mode, passes expected transform options to getCacheKey', async () => { config = { ...config, - transform: [['\\.js$', 'test_preprocessor', {configKey: 'configValue'}]], + transform: [ + [ + '\\.js$', + `${__dirname}/test_preprocessor`, + {configKey: 'configValue'}, + ], + ], }; const scriptTransformer = await createScriptTransformer(config); @@ -1371,7 +1476,7 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKey} = require('test_preprocessor'); + const {getCacheKey} = require(`${__dirname}/test_preprocessor`); expect(getCacheKey).toMatchSnapshot(); }); @@ -1379,7 +1484,11 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', 'test_async_preprocessor', {configKey: 'configValue'}], + [ + '\\.js$', + `${__dirname}/test_async_preprocessor`, + {configKey: 'configValue'}, + ], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -1389,27 +1498,33 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKeyAsync} = require('test_async_preprocessor'); + const {getCacheKeyAsync} = require(`${__dirname}/test_async_preprocessor`); expect(getCacheKeyAsync).toMatchSnapshot(); }); it('creates transformer with config', async () => { const transformerConfig = {}; config = Object.assign(config, { - transform: [['\\.js$', 'configureable-preprocessor', transformerConfig]], + transform: [ + [ + '\\.js$', + `${__dirname}/configureable-preprocessor`, + transformerConfig, + ], + ], }); const scriptTransformer = await createScriptTransformer(config); scriptTransformer.transform('/fruits/banana.js', {}); expect( - require('configureable-preprocessor').createTransformer, + require(`${__dirname}/configureable-preprocessor`).createTransformer, ).toHaveBeenCalledWith(transformerConfig); }); it('reads values from the cache', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); @@ -1450,7 +1565,7 @@ describe('ScriptTransformer', () => { it('in async mode, reads values from the cache', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1500,7 +1615,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache when using async preprocessor', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_async_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1550,7 +1665,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); scriptTransformer.transform( @@ -1581,7 +1696,7 @@ describe('ScriptTransformer', () => { it('in async mode, reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1612,7 +1727,7 @@ describe('ScriptTransformer', () => { it('with async preprocessor, reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', 'test_async_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1642,11 +1757,11 @@ describe('ScriptTransformer', () => { it('should reuse the value from in-memory cache which is set by custom transformer', async () => { const cacheFS = new Map(); - const testPreprocessor = require('cache_fs_preprocessor'); + const testPreprocessor = require(`${__dirname}/cache_fs_preprocessor`); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', 'cache_fs_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/cache_fs_preprocessor`, {}]], }, cacheFS, ); @@ -1667,11 +1782,11 @@ describe('ScriptTransformer', () => { it('in async mode, should reuse the value from in-memory cache which is set by custom preprocessor', async () => { const cacheFS = new Map(); - const testPreprocessor = require('cache_fs_preprocessor'); + const testPreprocessor = require(`${__dirname}/cache_fs_preprocessor`); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', 'cache_fs_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/cache_fs_preprocessor`, {}]], }, cacheFS, ); @@ -1692,11 +1807,11 @@ describe('ScriptTransformer', () => { it('should reuse the value from in-memory cache which is set by custom async preprocessor', async () => { const cacheFS = new Map(); - const testPreprocessor = require('cache_fs_async_preprocessor'); + const testPreprocessor = require(`${__dirname}/cache_fs_async_preprocessor`); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', 'cache_fs_async_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/cache_fs_async_preprocessor`, {}]], }, cacheFS, ); @@ -1722,14 +1837,14 @@ describe('ScriptTransformer', () => { it('does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'css-preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], }); anotherScriptTransformer.transform( @@ -1744,7 +1859,7 @@ describe('ScriptTransformer', () => { it('async mode does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }); await scriptTransformer.transformAsync( @@ -1754,7 +1869,7 @@ describe('ScriptTransformer', () => { const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'css-preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], }); await anotherScriptTransformer.transformAsync( @@ -1769,14 +1884,14 @@ describe('ScriptTransformer', () => { it('regardless of sync/async, does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'css-preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], }); await anotherScriptTransformer.transformAsync( @@ -1786,7 +1901,7 @@ describe('ScriptTransformer', () => { const yetAnotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }); yetAnotherScriptTransformer.transform( '/fruits/banana.js', @@ -1795,7 +1910,7 @@ describe('ScriptTransformer', () => { const fruityScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_async_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], }); await fruityScriptTransformer.transformAsync( '/fruits/banana.js', @@ -1809,11 +1924,11 @@ describe('ScriptTransformer', () => { it('preload transformer when using `createScriptTransformer`', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', 'test_preprocessor', {}]], + transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], }); expect(Array.from(scriptTransformer._transformCache.entries())).toEqual([ - ['test_preprocessor', expect.any(Object)], + [`${__dirname}/test_preprocessor`, expect.any(Object)], ]); }); }); diff --git a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap index 30afd6905c65..e6e281cd5989 100644 --- a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap +++ b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap @@ -109,7 +109,7 @@ exports[`ScriptTransformer in async mode, uses the supplied async preprocessor 1 const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_async_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_async_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_async_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_async_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -119,13 +119,13 @@ exports[`ScriptTransformer in async mode, uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; exports[`ScriptTransformer in async mode, uses the supplied preprocessor 2`] = `module.exports = "react";`; -exports[`ScriptTransformer in async mode, warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer in async mode, warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; exports[`ScriptTransformer passes expected transform options to getCacheKey 1`] = ` [MockFunction] { @@ -645,7 +645,7 @@ exports[`ScriptTransformer uses mixture of sync/async preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_async_preprocessor",{}],["\\\\.css$","css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_async_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_async_preprocessor",{}],["\\\\.css$","/css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_async_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"/css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -662,7 +662,7 @@ exports[`ScriptTransformer uses multiple preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}],["\\\\.css$","css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}],["\\\\.css$","/css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"/css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -679,12 +679,12 @@ exports[`ScriptTransformer uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; exports[`ScriptTransformer uses the supplied preprocessor 2`] = `module.exports = "react";`; -exports[`ScriptTransformer warns of unparseable inlined source maps from the async preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by async-preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer warns of unparseable inlined source maps from the async preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /async-preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; -exports[`ScriptTransformer warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; From fabc3301af8327d19a130903587744a0d5caba54 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 28 May 2021 14:20:11 +0200 Subject: [PATCH 4/5] Revert "fix almost all tests" This reverts commit 99c1122bc2b60d7dd21592746be4e4667a8542d0. --- .../src/__tests__/TestScheduler.test.js | 28 +- .../src/__tests__/ScriptTransformer.test.ts | 395 +++++++----------- .../ScriptTransformer.test.ts.snap | 16 +- 3 files changed, 160 insertions(+), 279 deletions(-) diff --git a/packages/jest-core/src/__tests__/TestScheduler.test.js b/packages/jest-core/src/__tests__/TestScheduler.test.js index 7b6f4e54dbba..b707ef3289c9 100644 --- a/packages/jest-core/src/__tests__/TestScheduler.test.js +++ b/packages/jest-core/src/__tests__/TestScheduler.test.js @@ -16,20 +16,16 @@ const mockSerialRunner = { isSerial: true, runTests: jest.fn(), }; -jest.mock( - `${__dirname}/jest-runner-serial`, - () => jest.fn(() => mockSerialRunner), - {virtual: true}, -); +jest.mock('jest-runner-serial', () => jest.fn(() => mockSerialRunner), { + virtual: true, +}); const mockParallelRunner = { runTests: jest.fn(), }; -jest.mock( - `${__dirname}/jest-runner-parallel`, - () => jest.fn(() => mockParallelRunner), - {virtual: true}, -); +jest.mock('jest-runner-parallel', () => jest.fn(() => mockParallelRunner), { + virtual: true, +}); const spyShouldRunInBand = jest.spyOn(testSchedulerHelper, 'shouldRunInBand'); @@ -93,7 +89,7 @@ test('schedule tests run in parallel per default', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: `${__dirname}/jest-runner-parallel`, + runner: 'jest-runner-parallel', transform: [], }), hasteFS: { @@ -116,7 +112,7 @@ test('schedule tests run in serial if the runner flags them', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: `${__dirname}/jest-runner-serial`, + runner: 'jest-runner-serial', transform: [], }), hasteFS: { @@ -140,7 +136,7 @@ test('should bail after `n` failures', async () => { config: makeProjectConfig({ moduleFileExtensions: ['.js'], rootDir: './', - runner: `${__dirname}/jest-runner-serial`, + runner: 'jest-runner-serial', transform: [], }), hasteFS: { @@ -172,7 +168,7 @@ test('should not bail if less than `n` failures', async () => { config: makeProjectConfig({ moduleFileExtensions: ['.js'], rootDir: './', - runner: `${__dirname}/jest-runner-serial`, + runner: 'jest-runner-serial', transform: [], }), hasteFS: { @@ -203,7 +199,7 @@ test('should set runInBand to run in serial', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: `${__dirname}/jest-runner-parallel`, + runner: 'jest-runner-parallel', transform: [], }), hasteFS: { @@ -229,7 +225,7 @@ test('should set runInBand to not run in serial', async () => { context: { config: makeProjectConfig({ moduleFileExtensions: ['.js'], - runner: `${__dirname}/jest-runner-parallel`, + runner: 'jest-runner-parallel', transform: [], }), hasteFS: { diff --git a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts index 15512d12cef0..94ade78a4a2c 100644 --- a/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts +++ b/packages/jest-transform/src/__tests__/ScriptTransformer.test.ts @@ -52,10 +52,9 @@ jest .mock('path', () => jest.requireActual('path').posix); jest.mock( - `${__dirname}/test_preprocessor`, + 'test_preprocessor', () => { - const escapeStrings = (str: string) => - str.replace(/'/, `'`).replace(new RegExp(__dirname, 'g'), ''); + const escapeStrings = (str: string) => str.replace(/'/, `'`); const transformer: Transformer = { getCacheKey: jest.fn(() => 'ab'), @@ -74,10 +73,9 @@ jest.mock( ); jest.mock( - `${__dirname}/test_async_preprocessor`, + 'test_async_preprocessor', () => { - const escapeStrings = (str: string) => - str.replace(/'/, `'`).replace(new RegExp(__dirname, 'g'), ''); + const escapeStrings = (str: string) => str.replace(/'/, `'`); const transformer: Transformer = { getCacheKeyAsync: jest.fn().mockResolvedValue('ab'), @@ -97,7 +95,7 @@ jest.mock( ); jest.mock( - `${__dirname}/configureable-preprocessor`, + 'configureable-preprocessor', () => ({ createTransformer: jest.fn(() => ({ process: jest.fn(() => 'processedCode'), @@ -107,7 +105,7 @@ jest.mock( ); jest.mock( - `${__dirname}/cache_fs_preprocessor`, + 'cache_fs_preprocessor', () => ({ getCacheKey: jest.fn(() => 'ab'), process: jest.fn(() => 'processedCode'), @@ -116,7 +114,7 @@ jest.mock( ); jest.mock( - `${__dirname}/cache_fs_async_preprocessor`, + 'cache_fs_async_preprocessor', () => ({ getCacheKeyAsync: jest.fn().mockResolvedValue('ab'), processAsync: jest.fn().mockResolvedValue('processedCode'), @@ -125,7 +123,7 @@ jest.mock( ); jest.mock( - `${__dirname}/preprocessor-with-sourcemaps`, + 'preprocessor-with-sourcemaps', () => ({ getCacheKey: jest.fn(() => 'ab'), process: jest.fn(), @@ -134,7 +132,7 @@ jest.mock( ); jest.mock( - `${__dirname}/async-preprocessor-with-sourcemaps`, + 'async-preprocessor-with-sourcemaps', () => ({ getCacheKeyAsync: jest.fn(() => 'ab'), processAsync: jest.fn(), @@ -143,7 +141,7 @@ jest.mock( ); jest.mock( - `${__dirname}/css-preprocessor`, + 'css-preprocessor', () => { const transformer: Transformer = { getCacheKey: jest.fn(() => 'cd'), @@ -160,34 +158,30 @@ jest.mock( {virtual: true}, ); -jest.mock( - `${__dirname}/passthrough-preprocessor`, - () => ({process: jest.fn()}), - {virtual: true}, -); - -// Bad preprocessor -jest.mock(`${__dirname}/skipped-required-props-preprocessor`, () => ({}), { +jest.mock('passthrough-preprocessor', () => ({process: jest.fn()}), { virtual: true, }); +// Bad preprocessor +jest.mock('skipped-required-props-preprocessor', () => ({}), {virtual: true}); + // Bad preprocessor jest.mock( - `${__dirname}/skipped-required-props-preprocessor-only-sync`, + 'skipped-required-props-preprocessor-only-sync', () => ({process: () => ''}), {virtual: true}, ); // Bad preprocessor jest.mock( - `${__dirname}/skipped-required-props-preprocessor-only-async`, + 'skipped-required-props-preprocessor-only-async', () => ({processAsync: async () => ''}), {virtual: true}, ); // Bad preprocessor jest.mock( - `${__dirname}/skipped-required-create-transformer-props-preprocessor`, + 'skipped-required-create-transformer-props-preprocessor', () => ({ createTransformer() { return {}; @@ -197,7 +191,7 @@ jest.mock( ); jest.mock( - `${__dirname}/skipped-process-method-preprocessor`, + 'skipped-process-method-preprocessor', () => ({ createTransformer() { return {process: jest.fn(() => 'code')}; @@ -207,7 +201,7 @@ jest.mock( ); jest.mock( - `${__dirname}/factory-for-async-preprocessor`, + 'factory-for-async-preprocessor', () => ({ createTransformer() { return {processAsync: jest.fn().mockResolvedValue('code')}; @@ -406,7 +400,7 @@ describe('ScriptTransformer', () => { it("throws an error if `process` doesn't return a string or an object containing `code` key with processed string", async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/passthrough-preprocessor`, {}]], + transform: [['\\.js$', 'passthrough-preprocessor', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -418,9 +412,7 @@ describe('ScriptTransformer', () => { incorrectReturnValues.forEach(([returnValue, filePath]) => { invariant(typeof filePath === 'string'); - require(`${__dirname}/passthrough-preprocessor`).process.mockReturnValue( - returnValue, - ); + require('passthrough-preprocessor').process.mockReturnValue(returnValue); expect(() => scriptTransformer.transform(filePath, getCoverageOptions()), ).toThrow('must return a string'); @@ -433,9 +425,7 @@ describe('ScriptTransformer', () => { correctReturnValues.forEach(([returnValue, filePath]) => { invariant(typeof filePath === 'string'); - require(`${__dirname}/passthrough-preprocessor`).process.mockReturnValue( - returnValue, - ); + require('passthrough-preprocessor').process.mockReturnValue(returnValue); expect(() => scriptTransformer.transform(filePath, getCoverageOptions()), ).not.toThrow(); @@ -455,7 +445,7 @@ describe('ScriptTransformer', () => { ]; const buildPromise = async ([returnValue, filePath]): Promise => { - const processorName = `${__dirname}/passthrough-preprocessor${filePath.replace( + const processorName = `passthrough-preprocessor${filePath.replace( /\.|\//g, '-', )}`; @@ -499,9 +489,7 @@ describe('ScriptTransformer', () => { it('throws an error if neither `process` nor `processAsync is defined', async () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/skipped-required-props-preprocessor`, {}], - ], + transform: [['\\.js$', 'skipped-required-props-preprocessor', {}]], }; await expect(() => createScriptTransformer(config)).rejects.toThrow( 'Jest: a transform must export a `process` or `processAsync` function.', @@ -512,18 +500,14 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - [ - '\\.js$', - `${__dirname}/skipped-required-props-preprocessor-only-async`, - {}, - ], + ['\\.js$', 'skipped-required-props-preprocessor-only-async', {}], ], }; const scriptTransformer = await createScriptTransformer(config); expect(() => scriptTransformer.transformSource('sample.js', '', {instrument: false}), ).toThrow( - `Jest: synchronous transformer ${__dirname}/skipped-required-props-preprocessor-only-async must export a "process" function.`, + 'Jest: synchronous transformer skipped-required-props-preprocessor-only-async must export a "process" function.', ); }); @@ -531,11 +515,7 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - [ - '\\.js$', - `${__dirname}/skipped-required-props-preprocessor-only-sync`, - {}, - ], + ['\\.js$', 'skipped-required-props-preprocessor-only-sync', {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -552,7 +532,7 @@ describe('ScriptTransformer', () => { transform: [ [ '\\.js$', - `${__dirname}/skipped-required-create-transformer-props-preprocessor`, + 'skipped-required-create-transformer-props-preprocessor', {}, ], ], @@ -565,9 +545,7 @@ describe('ScriptTransformer', () => { it("shouldn't throw error without process method. But with correct createTransformer method", async () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/skipped-process-method-preprocessor`, {}], - ], + transform: [['\\.js$', 'skipped-process-method-preprocessor', {}]], }; const scriptTransformer = await createScriptTransformer(config); expect(() => @@ -579,12 +557,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['async-sample.js', `${__dirname}/factory-for-async-preprocessor`, {}], - [ - 'sync-sample.js', - `${__dirname}/skipped-process-method-preprocessor`, - {}, - ], + ['async-sample.js', 'factory-for-async-preprocessor', {}], + ['sync-sample.js', 'skipped-process-method-preprocessor', {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -603,17 +577,14 @@ describe('ScriptTransformer', () => { }); it('uses the supplied preprocessor', async () => { - config = { - ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], - }; + config = {...config, transform: [['\\.js$', 'test_preprocessor', {}]]}; const scriptTransformer = await createScriptTransformer(config); const res1 = scriptTransformer.transform( '/fruits/banana.js', getCoverageOptions(), ); - expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); + expect(require('test_preprocessor').getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -626,17 +597,14 @@ describe('ScriptTransformer', () => { }); it('in async mode, uses the supplied preprocessor', async () => { - config = { - ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], - }; + config = {...config, transform: [['\\.js$', 'test_preprocessor', {}]]}; const scriptTransformer = await createScriptTransformer(config); const res1 = await scriptTransformer.transformAsync( '/fruits/banana.js', getCoverageOptions(), ); - expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); + expect(require('test_preprocessor').getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -651,7 +619,7 @@ describe('ScriptTransformer', () => { it('in async mode, uses the supplied async preprocessor', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], + transform: [['\\.js$', 'test_async_preprocessor', {}]], }; const scriptTransformer = await createScriptTransformer(config); const res1 = await scriptTransformer.transformAsync( @@ -659,9 +627,7 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect( - require(`${__dirname}/test_async_preprocessor`).getCacheKeyAsync, - ).toBeCalled(); + expect(require('test_async_preprocessor').getCacheKeyAsync).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); @@ -677,8 +643,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', `${__dirname}/test_preprocessor`, {}], - ['\\.css$', `${__dirname}/css-preprocessor`, {}], + ['\\.js$', 'test_preprocessor', {}], + ['\\.css$', 'css-preprocessor', {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -692,8 +658,8 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect(require(`${__dirname}/test_preprocessor`).getCacheKey).toBeCalled(); - expect(require(`${__dirname}/css-preprocessor`).getCacheKey).toBeCalled(); + expect(require('test_preprocessor').getCacheKey).toBeCalled(); + expect(require('css-preprocessor').getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); expect(wrap(res2.code)).toMatchSnapshot(); @@ -709,8 +675,8 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - ['\\.js$', `${__dirname}/test_async_preprocessor`, {}], - ['\\.css$', `${__dirname}/css-preprocessor`, {}], + ['\\.js$', 'test_async_preprocessor', {}], + ['\\.css$', 'css-preprocessor', {}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -724,10 +690,8 @@ describe('ScriptTransformer', () => { getCoverageOptions(), ); - expect( - require(`${__dirname}/test_async_preprocessor`).getCacheKeyAsync, - ).toBeCalled(); - expect(require(`${__dirname}/css-preprocessor`).getCacheKey).toBeCalled(); + expect(require('test_async_preprocessor').getCacheKeyAsync).toBeCalled(); + expect(require('css-preprocessor').getCacheKey).toBeCalled(); expect(wrap(res1.code)).toMatchSnapshot(); expect(wrap(res2.code)).toMatchSnapshot(); @@ -742,7 +706,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor supplies it', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -751,12 +715,10 @@ describe('ScriptTransformer', () => { version: 3, }; - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map, + }); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -774,7 +736,7 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if preprocessor supplies it', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -783,12 +745,10 @@ describe('ScriptTransformer', () => { version: 3, }; - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map, + }); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -806,9 +766,7 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if async preprocessor supplies it', async () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], - ], + transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -817,7 +775,7 @@ describe('ScriptTransformer', () => { version: 3, }; - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( { code: 'content', map, @@ -840,7 +798,7 @@ describe('ScriptTransformer', () => { it('writes source map if preprocessor inlines it', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -854,9 +812,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - content, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue(content); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -874,7 +830,7 @@ describe('ScriptTransformer', () => { it('in async mode, writes source map if preprocessor inlines it', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -888,9 +844,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - content, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue(content); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -908,9 +862,7 @@ describe('ScriptTransformer', () => { it('writes source map if async preprocessor inlines it', async () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], - ], + transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -924,7 +876,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64'); - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( content, ); @@ -947,7 +899,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -962,9 +914,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - content, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue(content); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -974,14 +924,7 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect( - wrap( - console.warn.mock.calls[0][0].replace( - new RegExp(__dirname, 'g'), - '', - ), - ), - ).toMatchSnapshot(); + expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); console.warn = warn; }); @@ -991,7 +934,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1006,9 +949,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - content, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue(content); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1018,14 +959,7 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect( - wrap( - console.warn.mock.calls[0][0].replace( - new RegExp(__dirname, 'g'), - '', - ), - ), - ).toMatchSnapshot(); + expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); console.warn = warn; }); @@ -1035,9 +969,7 @@ describe('ScriptTransformer', () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], - ], + transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1052,7 +984,7 @@ describe('ScriptTransformer', () => { '//# sourceMappingURL=data:application/json;base64,' + Buffer.from(sourceMap).toString('base64').slice(0, 16); - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( content, ); @@ -1064,14 +996,7 @@ describe('ScriptTransformer', () => { expect(writeFileAtomic.sync).toBeCalledTimes(1); expect(console.warn).toHaveBeenCalledTimes(1); - expect( - wrap( - console.warn.mock.calls[0][0].replace( - new RegExp(__dirname, 'g'), - '', - ), - ), - ).toMatchSnapshot(); + expect(wrap(console.warn.mock.calls[0][0])).toMatchSnapshot(); console.warn = warn; }); @@ -1079,7 +1004,7 @@ describe('ScriptTransformer', () => { it('writes source maps if given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1088,12 +1013,10 @@ describe('ScriptTransformer', () => { version: 3, }; - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map, + }); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1114,16 +1037,14 @@ describe('ScriptTransformer', () => { it('does not write source map if not given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map: null, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map: null, + }); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1136,16 +1057,14 @@ describe('ScriptTransformer', () => { it('in async mode, does not write source map if not given by the transformer', async () => { config = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map: null, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map: null, + }); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1158,13 +1077,11 @@ describe('ScriptTransformer', () => { it('does not write source map if not given by the async preprocessor', async () => { config = { ...config, - transform: [ - ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], - ], + transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(config); - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( { code: 'content', map: null, @@ -1182,7 +1099,7 @@ describe('ScriptTransformer', () => { it('should write a source map for the instrumented file when transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1203,12 +1120,10 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map, + }); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1229,7 +1144,7 @@ describe('ScriptTransformer', () => { it('in async mode, should write a source map for the instrumented file when transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/preprocessor-with-sourcemaps`, {}]], + transform: [['\\.js$', 'preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1250,12 +1165,10 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map, + }); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1276,9 +1189,7 @@ describe('ScriptTransformer', () => { it('should write a source map for the instrumented file when async transformed', async () => { const transformerConfig: Config.ProjectConfig = { ...config, - transform: [ - ['\\.js$', `${__dirname}/async-preprocessor-with-sourcemaps`, {}], - ], + transform: [['\\.js$', 'async-preprocessor-with-sourcemaps', {}]], }; const scriptTransformer = await createScriptTransformer(transformerConfig); @@ -1299,7 +1210,7 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( { code: 'content', map, @@ -1337,12 +1248,10 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map: null, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map: null, + }); const result = scriptTransformer.transform( '/fruits/banana.js', @@ -1375,12 +1284,10 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/preprocessor-with-sourcemaps`).process.mockReturnValue( - { - code: 'content', - map: null, - }, - ); + require('preprocessor-with-sourcemaps').process.mockReturnValue({ + code: 'content', + map: null, + }); const result = await scriptTransformer.transformAsync( '/fruits/banana.js', @@ -1413,7 +1320,7 @@ describe('ScriptTransformer', () => { }; /* eslint-enable */ - require(`${__dirname}/async-preprocessor-with-sourcemaps`).processAsync.mockResolvedValue( + require('async-preprocessor-with-sourcemaps').processAsync.mockResolvedValue( { code: 'content', map: null, @@ -1439,13 +1346,7 @@ describe('ScriptTransformer', () => { it('passes expected transform options to getCacheKey', async () => { config = { ...config, - transform: [ - [ - '\\.js$', - `${__dirname}/test_preprocessor`, - {configKey: 'configValue'}, - ], - ], + transform: [['\\.js$', 'test_preprocessor', {configKey: 'configValue'}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1454,20 +1355,14 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKey} = require(`${__dirname}/test_preprocessor`); + const {getCacheKey} = require('test_preprocessor'); expect(getCacheKey).toMatchSnapshot(); }); it('in async mode, passes expected transform options to getCacheKey', async () => { config = { ...config, - transform: [ - [ - '\\.js$', - `${__dirname}/test_preprocessor`, - {configKey: 'configValue'}, - ], - ], + transform: [['\\.js$', 'test_preprocessor', {configKey: 'configValue'}]], }; const scriptTransformer = await createScriptTransformer(config); @@ -1476,7 +1371,7 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKey} = require(`${__dirname}/test_preprocessor`); + const {getCacheKey} = require('test_preprocessor'); expect(getCacheKey).toMatchSnapshot(); }); @@ -1484,11 +1379,7 @@ describe('ScriptTransformer', () => { config = { ...config, transform: [ - [ - '\\.js$', - `${__dirname}/test_async_preprocessor`, - {configKey: 'configValue'}, - ], + ['\\.js$', 'test_async_preprocessor', {configKey: 'configValue'}], ], }; const scriptTransformer = await createScriptTransformer(config); @@ -1498,33 +1389,27 @@ describe('ScriptTransformer', () => { getCoverageOptions({collectCoverage: true}), ); - const {getCacheKeyAsync} = require(`${__dirname}/test_async_preprocessor`); + const {getCacheKeyAsync} = require('test_async_preprocessor'); expect(getCacheKeyAsync).toMatchSnapshot(); }); it('creates transformer with config', async () => { const transformerConfig = {}; config = Object.assign(config, { - transform: [ - [ - '\\.js$', - `${__dirname}/configureable-preprocessor`, - transformerConfig, - ], - ], + transform: [['\\.js$', 'configureable-preprocessor', transformerConfig]], }); const scriptTransformer = await createScriptTransformer(config); scriptTransformer.transform('/fruits/banana.js', {}); expect( - require(`${__dirname}/configureable-preprocessor`).createTransformer, + require('configureable-preprocessor').createTransformer, ).toHaveBeenCalledWith(transformerConfig); }); it('reads values from the cache', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); @@ -1565,7 +1450,7 @@ describe('ScriptTransformer', () => { it('in async mode, reads values from the cache', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1615,7 +1500,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache when using async preprocessor', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], + transform: [['\\.js$', 'test_async_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1665,7 +1550,7 @@ describe('ScriptTransformer', () => { it('reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); scriptTransformer.transform( @@ -1696,7 +1581,7 @@ describe('ScriptTransformer', () => { it('in async mode, reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1727,7 +1612,7 @@ describe('ScriptTransformer', () => { it('with async preprocessor, reads values from the cache when the file contains colons', async () => { const transformConfig: Config.ProjectConfig = { ...config, - transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], + transform: [['\\.js$', 'test_async_preprocessor', {}]], }; let scriptTransformer = await createScriptTransformer(transformConfig); await scriptTransformer.transformAsync( @@ -1757,11 +1642,11 @@ describe('ScriptTransformer', () => { it('should reuse the value from in-memory cache which is set by custom transformer', async () => { const cacheFS = new Map(); - const testPreprocessor = require(`${__dirname}/cache_fs_preprocessor`); + const testPreprocessor = require('cache_fs_preprocessor'); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', `${__dirname}/cache_fs_preprocessor`, {}]], + transform: [['\\.js$', 'cache_fs_preprocessor', {}]], }, cacheFS, ); @@ -1782,11 +1667,11 @@ describe('ScriptTransformer', () => { it('in async mode, should reuse the value from in-memory cache which is set by custom preprocessor', async () => { const cacheFS = new Map(); - const testPreprocessor = require(`${__dirname}/cache_fs_preprocessor`); + const testPreprocessor = require('cache_fs_preprocessor'); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', `${__dirname}/cache_fs_preprocessor`, {}]], + transform: [['\\.js$', 'cache_fs_preprocessor', {}]], }, cacheFS, ); @@ -1807,11 +1692,11 @@ describe('ScriptTransformer', () => { it('should reuse the value from in-memory cache which is set by custom async preprocessor', async () => { const cacheFS = new Map(); - const testPreprocessor = require(`${__dirname}/cache_fs_async_preprocessor`); + const testPreprocessor = require('cache_fs_async_preprocessor'); const scriptTransformer = await createScriptTransformer( { ...config, - transform: [['\\.js$', `${__dirname}/cache_fs_async_preprocessor`, {}]], + transform: [['\\.js$', 'cache_fs_async_preprocessor', {}]], }, cacheFS, ); @@ -1837,14 +1722,14 @@ describe('ScriptTransformer', () => { it('does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], + transform: [['\\.js$', 'css-preprocessor', {}]], }); anotherScriptTransformer.transform( @@ -1859,7 +1744,7 @@ describe('ScriptTransformer', () => { it('async mode does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }); await scriptTransformer.transformAsync( @@ -1869,7 +1754,7 @@ describe('ScriptTransformer', () => { const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], + transform: [['\\.js$', 'css-preprocessor', {}]], }); await anotherScriptTransformer.transformAsync( @@ -1884,14 +1769,14 @@ describe('ScriptTransformer', () => { it('regardless of sync/async, does not reuse the in-memory cache between different projects', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }); scriptTransformer.transform('/fruits/banana.js', getCoverageOptions()); const anotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/css-preprocessor`, {}]], + transform: [['\\.js$', 'css-preprocessor', {}]], }); await anotherScriptTransformer.transformAsync( @@ -1901,7 +1786,7 @@ describe('ScriptTransformer', () => { const yetAnotherScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }); yetAnotherScriptTransformer.transform( '/fruits/banana.js', @@ -1910,7 +1795,7 @@ describe('ScriptTransformer', () => { const fruityScriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_async_preprocessor`, {}]], + transform: [['\\.js$', 'test_async_preprocessor', {}]], }); await fruityScriptTransformer.transformAsync( '/fruits/banana.js', @@ -1924,11 +1809,11 @@ describe('ScriptTransformer', () => { it('preload transformer when using `createScriptTransformer`', async () => { const scriptTransformer = await createScriptTransformer({ ...config, - transform: [['\\.js$', `${__dirname}/test_preprocessor`, {}]], + transform: [['\\.js$', 'test_preprocessor', {}]], }); expect(Array.from(scriptTransformer._transformCache.entries())).toEqual([ - [`${__dirname}/test_preprocessor`, expect.any(Object)], + ['test_preprocessor', expect.any(Object)], ]); }); }); diff --git a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap index e6e281cd5989..30afd6905c65 100644 --- a/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap +++ b/packages/jest-transform/src/__tests__/__snapshots__/ScriptTransformer.test.ts.snap @@ -109,7 +109,7 @@ exports[`ScriptTransformer in async mode, uses the supplied async preprocessor 1 const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_async_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_async_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_async_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_async_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -119,13 +119,13 @@ exports[`ScriptTransformer in async mode, uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; exports[`ScriptTransformer in async mode, uses the supplied preprocessor 2`] = `module.exports = "react";`; -exports[`ScriptTransformer in async mode, warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer in async mode, warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; exports[`ScriptTransformer passes expected transform options to getCacheKey 1`] = ` [MockFunction] { @@ -645,7 +645,7 @@ exports[`ScriptTransformer uses mixture of sync/async preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_async_preprocessor",{}],["\\\\.css$","/css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_async_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"/css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_async_preprocessor",{}],["\\\\.css$","css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_async_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -662,7 +662,7 @@ exports[`ScriptTransformer uses multiple preprocessors 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}],["\\\\.css$","/css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"/css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}],["\\\\.css$","css-preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}],[\\"\\\\\\\\.css$\\",\\"css-preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; @@ -679,12 +679,12 @@ exports[`ScriptTransformer uses the supplied preprocessor 1`] = ` const TRANSFORMED = { filename: '/fruits/banana.js', script: 'module.exports = "banana";', - config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","/test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"/test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', + config: '{"collectCoverage":false,"collectCoverageFrom":[],"coverageProvider":"babel","supportsDynamicImport":false,"supportsExportNamespaceFrom":false,"supportsStaticESM":false,"supportsTopLevelAwait":false,"instrument":false,"cacheFS":{},"config":{"automock":false,"cache":true,"cacheDirectory":"/cache/","clearMocks":false,"coveragePathIgnorePatterns":[],"cwd":"/test_root_dir/","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"extensionsToTreatAsEsm":[],"extraGlobals":[],"forceCoverageMatch":[],"globals":{},"haste":{},"injectGlobals":true,"moduleDirectories":[],"moduleFileExtensions":["js"],"moduleLoader":"/test_module_loader_path","moduleNameMapper":[],"modulePathIgnorePatterns":[],"modulePaths":[],"name":"test","prettierPath":"prettier","resetMocks":false,"resetModules":false,"restoreMocks":false,"rootDir":"/","roots":[],"runner":"jest-runner","setupFiles":[],"setupFilesAfterEnv":[],"skipFilter":false,"skipNodeResolution":false,"slowTestThreshold":5,"snapshotSerializers":[],"testEnvironment":"node","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":[],"testRegex":["\\\\.test\\\\.js$"],"testRunner":"jest-circus/runner","testURL":"http://localhost","timers":"real","transform":[["\\\\.js$","test_preprocessor",{}]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"configString":"{\\"automock\\":false,\\"cache\\":true,\\"cacheDirectory\\":\\"/cache/\\",\\"clearMocks\\":false,\\"coveragePathIgnorePatterns\\":[],\\"cwd\\":\\"/test_root_dir/\\",\\"detectLeaks\\":false,\\"detectOpenHandles\\":false,\\"errorOnDeprecated\\":false,\\"extensionsToTreatAsEsm\\":[],\\"extraGlobals\\":[],\\"forceCoverageMatch\\":[],\\"globals\\":{},\\"haste\\":{},\\"injectGlobals\\":true,\\"moduleDirectories\\":[],\\"moduleFileExtensions\\":[\\"js\\"],\\"moduleLoader\\":\\"/test_module_loader_path\\",\\"moduleNameMapper\\":[],\\"modulePathIgnorePatterns\\":[],\\"modulePaths\\":[],\\"name\\":\\"test\\",\\"prettierPath\\":\\"prettier\\",\\"resetMocks\\":false,\\"resetModules\\":false,\\"restoreMocks\\":false,\\"rootDir\\":\\"/\\",\\"roots\\":[],\\"runner\\":\\"jest-runner\\",\\"setupFiles\\":[],\\"setupFilesAfterEnv\\":[],\\"skipFilter\\":false,\\"skipNodeResolution\\":false,\\"slowTestThreshold\\":5,\\"snapshotSerializers\\":[],\\"testEnvironment\\":\\"node\\",\\"testEnvironmentOptions\\":{},\\"testLocationInResults\\":false,\\"testMatch\\":[],\\"testPathIgnorePatterns\\":[],\\"testRegex\\":[\\"\\\\\\\\.test\\\\\\\\.js$\\"],\\"testRunner\\":\\"jest-circus/runner\\",\\"testURL\\":\\"http://localhost\\",\\"timers\\":\\"real\\",\\"transform\\":[[\\"\\\\\\\\.js$\\",\\"test_preprocessor\\",{}]],\\"transformIgnorePatterns\\":[\\"/node_modules/\\"],\\"watchPathIgnorePatterns\\":[]}","transformerConfig":{}}', }; `; exports[`ScriptTransformer uses the supplied preprocessor 2`] = `module.exports = "react";`; -exports[`ScriptTransformer warns of unparseable inlined source maps from the async preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /async-preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer warns of unparseable inlined source maps from the async preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by async-preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; -exports[`ScriptTransformer warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by /preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; +exports[`ScriptTransformer warns of unparseable inlined source maps from the preprocessor 1`] = `jest-transform: The source map produced for the file /fruits/banana.js by preprocessor-with-sourcemaps was invalid. Proceeding without source mapping for that file.`; From c4ea5bf342f8eac021efc4f63f1f74a31d08fb4e Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Fri, 28 May 2021 14:20:43 +0200 Subject: [PATCH 5/5] rollback breaking change --- packages/jest-util/src/requireOrImportModule.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-util/src/requireOrImportModule.ts b/packages/jest-util/src/requireOrImportModule.ts index a2709f0a8aee..bd93854d3e71 100644 --- a/packages/jest-util/src/requireOrImportModule.ts +++ b/packages/jest-util/src/requireOrImportModule.ts @@ -14,7 +14,7 @@ export default async function requireOrImportModule( filePath: Config.Path, applyInteropRequireDefault = true, ): Promise { - if (!isAbsolute(filePath)) { + if (!isAbsolute(filePath) && filePath[0] === '.') { throw new Error( `Jest: requireOrImportModule path must be absolute, was "${filePath}"`, );