Skip to content

Jest won't recompile CSS modules when their dependencies change unless you wipe Jest's cache #48

Description

@nskazki

Issue

Jest won't recompile CSS modules when their dependencies change unless you wipe Jest's cache.

Reproduction Link

https://github.com/nskazki/jest-wont-recompile-css-modules

How to Reproduce

I've defined a SCSS variable in the color.scss, re-exported that variable via the module.scss, re-exported it again via the color.js, so that I can finally inspect it in the color.spec.js.

  1. Run the color.spec.js using npm run test. It should fail because the variable is actually red while it's expected to be green.
  2. Fix the variable's value, echo '$color: green;' > src/color.scss.
  3. Run the same spec again using the same command. It shouldn't have failed but it will because the wrong value is stuck in cache!
  4. Ignore the cache using npm run test-no-cache. It should pass this time.

Why Dependencies?

If you define the variable right in the module.scss instead of importing it from the color.scss, the problem with cache won't bother you. So, the problem has to do with dependencies.

Activity

  1. Connormiha commented on May 1, 2022

    @Connormiha
    Owner

    @nskazki Thanks for report and sorry for delay. I will try to fix it soon.

  2. nskazki commented on Jun 2, 2022

    @nskazki
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions