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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token import for symlink (not for relative path) #2591

Closed
AvraamMavridis opened this issue Jan 13, 2017 · 2 comments
Closed

Unexpected token import for symlink (not for relative path) #2591

AvraamMavridis opened this issue Jan 13, 2017 · 2 comments

Comments

@AvraamMavridis
Copy link
Contributor

For my application I create a symlink inside the node_modules so, I dont have to use relative paths for import, and my test looks like

import Dictionary from 'myapp/utils/Dictionary';

describe('Dictionary', () => {

  it('should return the same text if no definition found', () =>{
    const text = 'This is 100% not in the dictionary';
    expect(Dictionary.instant(text)).toEqual(text);
  });
});

Where myapp is the symlink inside the node_modules, using this way I am getting unexpected token import. If I use relative path, like ../../Dictionary everything works fine. Is it a way to achieve that? I am suspecting it has to do with the transformation config but I couldnt figure out.

My settings look like

  "jest": {
    "setupTestFrameworkScriptFile": "./app/src/jest.init.js",
    "verbose": true,
    "testRegex": "(/__tests__/.*|(\\.|/)(jest))\\.jsx?$",
    "moduleFileExtensions": [
      "js",
      "jsx"
    ],
    "automock": false,
    "collectCoverage": true,
    "coverageDirectory": "./coverage",
    "coverageReporters": [
      "json",
      "text",
      "html"
    ],
    "coverageCollector": "jest-babel-istanbul"
  },
@cpojer
Copy link
Member

cpojer commented Jan 13, 2017

You need to adjust transformIgnorePatterns to whitelist those node modules. By default, Jest doesn't transform files in node modules folders.

@cpojer cpojer closed this as completed Jan 13, 2017
@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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants