jest: jest does not "activate" babel support when running on windows on a network-share

Do you want to request a feature or report a bug?

bug

What is the current behavior?

i am running jest in windows, in a directory that is a network-share (for example: \\server1\ is mounted as G:, and i am running the tests in G:\src\). (technically this is a mac-laptop, with parallels, windows in parallels, and my macos-directory is shared into the parallels-windows, and i am running jest on that shared directory in windows; but i assume this problem applies in general to any case where running on a network-drive in windows).

there is a .babelrc in the directory, so jest should automatically apply it but it does not, and then it fails with a syntaxerror on an import statement.

if i copy my project from this shared-disk to the C:\ drive that is “native” windows, and run jest there, jest works correctly.

i can also workaround the issue by running jest --rootDir . instead of jest.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

it can be reproduced with the examples/react project from the jest-source-code:

have a network-share in windows, and copy the jest-source-code there. go to the examples/react folder, and try to run the tests there.

What is the expected behavior?

the tests should not fail.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

jest v22.3.0, windows 10, nodev8.9.4, yarn1.3.2

i tried to debug the issue and find the core of the problem, and it seems the following is happening:

  • the network-drive is mounted as a disk-drive in windows, so the directory with the tests is available at (for example) G:\src\ . but the real name of that place is \\server1\src . when i go to G:\src\, and start jest, it looks up the full-name of the current-directory, and somehow it gets the network-ish name (\\server\src). and it gets confused by the double-backslash at the beginning. but if i run it as jest --rootDir ., i assume it stays with the G:\src\ name, and then everything is ok.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Any updates on this?

I’m running babel 7. My jest.config.js looks like this:

// @ts-ignore
module.exports = {
  testEnvironment: 'node',
  roots: ['<rootDir>/src'],
  testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  collectCoverageFrom: ['src/**/*.{ts,tsx}'],
  clearMocks: true,
  setupFilesAfterEnv: ['<rootDir>/src/setupEnzyme.ts'],
  moduleNameMapper: {
    '\\.(gif|ttf|eot|svg)$': '<rootDir>/__mocks__/fileMock.js',
  },
};

And my .babel.config.js is

module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-typescript'],
  plugins: [
    '@babel/proposal-class-properties',
    '@babel/proposal-object-rest-spread',
  ],
};

When running either jest --rootDir . or jest, I’m getting the following error:

● Validation Error:

  Module ts-jest in the transform option was not found.
         <rootDir> is: \\Mac\Home\Dev\

It’s still broken!!

I arrived at this page when getting the fore-mentioned error.

MY PROBLEM WAS: I have ts-jest installed globally ONLY but I forgot to install it in my local project. I only had jest installed so the global ts-jest kicked in. After local install of ts-jest I was good to go.

Mostly likely my fix is completely unrelated to previous comments.