Jest: Module ts-jest in transform not found. Solved?

Created on 23 Apr 2018  路  3Comments  路  Source: facebook/jest

I want to report a _bug_

What is the current behavior?
I get an error running jest from a mapped network drive. Jest runs fine from a local drive.

I think this is related to:
https://github.com/facebook/jest/issues/5563

Error

Validation Error:

  Module ts-jest in the transform option was not found.

  Configuration Documentation:
  https://facebook.github.io/jest/docs/configuration.html

To repeat:

mkdir C:\test
cd C:\test\
git clone [email protected]:jhr007/test-typescript-app.git
cd test-typescript-app
npm install 
net use x: \\localhost\C$\test

Open x:\test-typescript-app\ in VS Code and hit (F5) to debug it with (vscode-jest-tests configuration).
and you should get the above error.

Open the same project from C:\testtest-typescript-app and the tests will run(tests didn't pass for me but at least it got that far). test-typescript-app was created with create-react-app my-app --scripts-version=react-scripts-ts per create a typescript

I _think_ I found the problem

It's in how path#join (now?) handles network paths at path.join(prefix, aPath, moduleDir);
https://github.com/facebook/jest/blob/master/packages/jest-resolve/src/node_modules_paths.js#L62

const path = require('path');

let prefix = '\\\\';
const aPath = '\\\\localhost\\C$\\test\\test-typescript-app';
const moduleDir = 'nodule_modules';

path.join(prefix, aPath, moduleDir); // returns '\\localhost....'  : Bad

prefix = '';
path.join(prefix, aPath, moduleDir); // returns '\\\\localhost....' : Good

Changing this line to prefix = ''; gets the tests to start/finish.
https://github.com/facebook/jest/blob/master/packages/jest-resolve/src/node_modules_paths.js#L38
I just think this is the regex and I'm a test noob. I got the tests in my other project to run with the VS Code Jest Extension by changing that line.

Maybe Line 35 should be

 if (process.platform === 'win32') {
    prefix = '';
  } 

What is the expected behavior?
I expect tests to run rather than getting an error.

Please provide your exact Jest configuration
The commit adding jest config to package.json

Run npx envinfo --preset jest in your project directory and paste the
results here

Original issue found using VS Code's Jest plugin:
https://github.com/jest-community/vscode-jest/issues/304

Most helpful comment

It's still broken!!

All 3 comments

Looks like the same issue: https://github.com/facebook/jest/issues/5563. I'll close this one, but please join discussion there with your findings.

It's still broken!!

It's still broken!!

Was this page helpful?
0 / 5 - 0 ratings