From 5d1be035cc7b12a25010941953a88fe3c20d0984 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 3 May 2020 22:34:03 +0200 Subject: [PATCH] chore: fix windows CI (#9964) --- e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap | 4 ++-- .../__snapshots__/resolveNoFileExtensions.test.ts.snap | 2 +- packages/jest-resolve/src/index.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap b/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap index d65a0391ff07..faac572b892d 100644 --- a/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap +++ b/e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap @@ -36,7 +36,7 @@ FAIL __tests__/index.js 12 | module.exports = () => 'test'; 13 | - at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:541:17) + at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:553:17) at Object.require (index.js:10:1) `; @@ -65,6 +65,6 @@ FAIL __tests__/index.js 12 | module.exports = () => 'test'; 13 | - at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:541:17) + at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:553:17) at Object.require (index.js:10:1) `; diff --git a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap index a62a66e69f80..5b14d65aaa83 100644 --- a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap +++ b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.ts.snap @@ -37,6 +37,6 @@ FAIL __tests__/test.js | ^ 9 | - at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:296:11) + at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:308:11) at Object.require (index.js:8:18) `; diff --git a/packages/jest-resolve/src/index.ts b/packages/jest-resolve/src/index.ts index c253cfa8aa71..b678dabbe3dc 100644 --- a/packages/jest-resolve/src/index.ts +++ b/packages/jest-resolve/src/index.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import type {Config} from '@jest/types'; import type {ModuleMap} from 'jest-haste-map'; import {tryRealpath} from 'jest-util'; +import slash = require('slash'); import nodeModulesPaths from './nodeModulesPaths'; import isBuiltinModule from './isBuiltinModule'; import defaultResolver, {clearDefaultResolverCache} from './defaultResolver'; @@ -236,7 +237,8 @@ class Resolver { // 5. Throw an error if the module could not be found. `resolve.sync` only // produces an error based on the dirname but we have the actual current // module name available. - const relativePath = path.relative(this._options.rootDir, from) || '.'; + const relativePath = + slash(path.relative(this._options.rootDir, from)) || '.'; throw new ModuleNotFoundError( `Cannot find module '${moduleName}' from '${relativePath}'`,