Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

File in node_modules not transformed (related to transformIgnorePatterns) #7578

Closed
volkanunsal opened this issue Jan 4, 2019 · 7 comments
Closed

Comments

@volkanunsal
Copy link

volkanunsal commented Jan 4, 2019

馃悰 Bug Report

In my jest config, I have the following:

transformIgnorePatterns: ['node_modules/(?!(react-apollo/test-links(.js)?))'],

And in my test file, I have this:

import { MockLink } from 'react-apollo/test-links';

And I get this error:

    Jest encountered an unexpected token

    webapp/node_modules/react-apollo/test-links.js:25
    import { ApolloLink, Observable } from 'apollo-link';
    ^^^^^^

    SyntaxError: Unexpected token import

    > 4 | import { MockLink } from 'react-apollo/test-links';
        | ^

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:404:17)
      at Object.<anonymous> (assets/comps/TcombFactories/__tests__/loaders-test.js:4:1)

Expected behavior

I have traced the file into script_transformer.js. The code is not transpiled, despite the fact that willTransform equals true. So transformSource is returning untransformed content:

const processed = transform.process(content, filename, this._config, {
   instrument: instrument
});

Both transformedSource.code and content are the same. I expect the result to be in ES5, but it's not.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz
  Binaries:
    Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
    Yarn: 1.12.3 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
  npmPackages:
    jest: ^23.0.0 => 23.6.0
@volkanunsal volkanunsal changed the title File in node_modules not transformed (related to transformIgnorePatterns) File in node_modules not transformed (related to transformIgnorePatterns) Jan 4, 2019
@lakatostamas
Copy link

Could you please include your babel config? If you're transpiling node_modules and you're using babel v7 you have to use babel.config.js(read more here: https://jestjs.io/docs/en/getting-started#using-babel)

@volkanunsal
Copy link
Author

Thanks, that fixes it.

@domkrel
Copy link

domkrel commented Apr 8, 2019

@volkanunsal how did you solve it?
Could you please share your configuration?

@volkanunsal
Copy link
Author

@domkrel I wasn't using a babel.config.js file.

@domkrel
Copy link

domkrel commented Apr 8, 2019

@volkanunsal thanks for the hint. I dropped my babel.rc in favor for babel.config.js now.

@deepakjha14
Copy link

I wonder if this still persists? I have just encountered the same problem and although i am using transformIgnorePatterns in package.json inside jest object. I have also used babel.config.js as mentioned however still the same issue. Just like @volkanunsal i have also debugged the script_transformer.js and found that the values are same however still the same issue :( any hint help?

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants