question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16

github_iconTop GitHub Comments

13reactions
ivancuriccommented, Feb 27, 2019

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\
4reactions
xameeramircommented, Jun 13, 2020

It’s still broken!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Babel throwing Support for the experimental syntax 'jsx' isn't ...
Looking at the error it looks its not able to load the preset for react. Switch to the config file and move the...
Read more >
Getting Started - Jest
Via babel ​ ... Jest supports TypeScript, via Babel. First, make sure you followed the instructions on using Babel above. Next, install the...
Read more >
Introduction: Troubleshooting - Wallaby.js
Wallaby.js issues are registered by using this repository. Whenever something goes wrong, please report an issue and we will address it as soon...
Read more >
The React Scripts Start Command – Create-React-App NPM ...
To run your React application, you need to turn your JSX into ... Although you can't see Babel or Webpack listed as dependencies...
Read more >
How I Fixed The Unexpected Token Error In Jest
So for the Jest tests to run, it first needs to be transpiled by Babel. If you don't get it properly transpiled, you'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found