Skip to content

/scss/ in preprocessorIgnorePatterns has no effect #870

@doque

Description

@doque

We're using CSS modules in our React components, which are importing .scss files, like this:

import styles from './ReviewFeedItem.scss';

To ignore them when running jest, I've excluded /scss/ from the module loader (or so I think):

// package.json

"preprocessorIgnorePatterns": [
  "/scss/"
],

However, when running the tests, the module loader still tries (and fails) to parse the .scss file as javascript and yields this error:

Runtime Error
SyntaxError: Unexpected token ILLEGAL in file 'src/components/navigation/Navigation.scss'.

Make sure your preprocessor is set up correctly and ensure your 'preprocessorIgnorePatterns' configuration is correct: http://facebook.github.io/jest/docs/api.html#config-preprocessorignorepatterns-array-string
If you are currently setting up Jest or modifying your preprocessor, try `jest --no-cache`.
Preprocessor: jest-preprocessor.js.
Jest tried to the execute the following preprocessed code:
body { height: 0; }

Any variation of the exclude Pattern, such as \\.scss, scss and so forth has no effect.
We're using babel-jest as the scriptPreprocessor (so no specific entry for that in package.json)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions