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

Assets imported from scoped folder treated as JS #1613

Closed
robcaldecott opened this issue Sep 5, 2016 · 3 comments
Closed

Assets imported from scoped folder treated as JS #1613

robcaldecott opened this issue Sep 5, 2016 · 3 comments

Comments

@robcaldecott
Copy link

I reported this in create-react-app:

facebook/create-react-app#579

If you use the Webpack feature to import an asset (CSS/images) from a scoped npm module then Jest will treat the asset as JS code and the test will fail.

import logo from '@myscope/my-component/logo.png'

Results in an error like this:

FAIL  src\App.test.js
  ● Test suite failed to run

    C:\Users\<user>\Projects\my-app\node_modules\@myscope\my-component\logo.png:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){�PNG
                                                                                             ^
    SyntaxError: Unexpected token ILLEGAL

      at transformAndBuildScript (node_modules\react-scripts\node_modules\jest-runtime\build\transform.js:284:10)
      at Object.<anonymous> (src\App.js:3:38)
      at Object.<anonymous> (src\App.test.js:3:38)
@fson
Copy link
Contributor

fson commented Sep 5, 2016

This turned out to be an issue in the Jest configuration used in create-react-app. Fixed in facebook/create-react-app#584.

@cpojer cpojer closed this as completed Sep 14, 2016
@cpojer
Copy link
Member

cpojer commented Sep 14, 2016

Thanks @fson!

@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 14, 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

3 participants