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

Caching causing issues #521

Closed
hgezim opened this issue Sep 25, 2015 · 6 comments
Closed

Caching causing issues #521

hgezim opened this issue Sep 25, 2015 · 6 comments

Comments

@hgezim
Copy link
Contributor

hgezim commented Sep 25, 2015

I discovered an issue that appears to be caused by caching. On the initial run of a test, it evaluates the test and determines that it fails (without errors), however on subsequent runs, I get: Cannot find module './emptyFunction' from 'node_modules/jest-cli/.haste_cache/preprocess-cache/warning_764896bb1571a8dbaa5c10886672e1b1.js':

I will demonstrate that in the following command line log. The first run is a subsequent run (not initial). I then reinstall jest-cli to remove caching and rerun the jest at which I get no errors. I then run it again and get the error.

$ jest "components/__tests__/Logs-test.js"
Using Jest CLI v0.5.8
 FAIL  components/__tests__/Logs-test.js (6.106s)
● Logs › it should render one log entry
  - Error: components/Logs.jsx: components/UI/Button.jsx: node_modules/react-router/lib/Link.js: node_modules/jest-cli/.haste_cache/preprocess-cache/warning_9639d273552fc3d10e9d82c0b9a7ffe7_0cf03796f2d31f7d5a0ad1dbaa0b1815.js: Cannot find module './emptyFunction' from 'node_modules/jest-cli/.haste_cache/preprocess-cache/warning_9639d273552fc3d10e9d82c0b9a7ffe7_0cf03796f2d31f7d5a0ad1dbaa0b1815.js'
      at Loader._getNormalizedModuleID (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:346:15)
      at Loader._shouldMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:555:23)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:917:12)
      at Object.<anonymous> (node_modules/jest-cli/.haste_cache/preprocess-cache/warning_9639d273552fc3d10e9d82c0b9a7ffe7_0cf03796f2d31f7d5a0ad1dbaa0b1815.js:14:21)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader._generateMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:267:30)
      at Loader.requireMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:795:43)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:918:17)
      at Object.<anonymous> (node_modules/react-router/lib/Link.js:15:16)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:920:17)
      at Object.<anonymous> (components/UI/Button.jsx:2:12)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader._generateMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:267:30)
      at Loader.requireMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:795:43)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:918:17)
      at Object.<anonymous> (components/Logs.jsx:7:14)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:920:17)
      at Spec.<anonymous> (components/__tests__/Logs-test.js:30:12)

  - Expected: 0 toBe: 1
        at Spec.<anonymous> (components/__tests__/Logs-test.js:56:15)
1 test failed, 0 tests passed (1 total)
Run time: 6.791s
$ rm -rf node_modules/jest-cli/
$ npm install jest-cli
jest-cli@0.5.8 # ... INSTALL OUTPUT ...
$ jest "components/__tests__/Logs-test.js"
Using Jest CLI v0.5.8
 FAIL  components/__tests__/Logs-test.js (17.728s)
● Logs › it should render one log entry
  - Expected: 0 toBe: 1
        at Spec.<anonymous> (components/__tests__/Logs-test.js:56:15)
1 test failed, 0 tests passed (1 total)
Run time: 18.284s
$ jest "components/__tests__/Logs-test.js"
Using Jest CLI v0.5.8
 FAIL  components/__tests__/Logs-test.js (6.197s)
● Logs › it should render one log entry
  - Error: components/Logs.jsx: components/UI/Button.jsx: node_modules/react-router/lib/Link.js: node_modules/jest-cli/.haste_cache/preprocess-cache/warning_764896bb1571a8dbaa5c10886672e1b1.js: Cannot find module './emptyFunction' from 'node_modules/jest-cli/.haste_cache/preprocess-cache/warning_764896bb1571a8dbaa5c10886672e1b1.js'
      at Loader._getNormalizedModuleID (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:346:15)
      at Loader._shouldMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:555:23)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:917:12)
      at Object.<anonymous> (node_modules/jest-cli/.haste_cache/preprocess-cache/warning_764896bb1571a8dbaa5c10886672e1b1.js:14:21)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader._generateMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:267:30)
      at Loader.requireMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:795:43)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:918:17)
      at Object.<anonymous> (node_modules/react-router/lib/Link.js:15:16)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:920:17)
      at Object.<anonymous> (components/UI/Button.jsx:2:12)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader._generateMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:267:30)
      at Loader.requireMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:795:43)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:918:17)
      at Object.<anonymous> (components/Logs.jsx:7:14)
      at Object.runContentWithLocalBindings (node_modules/jest-cli/src/lib/utils.js:517:17)
      at Loader._execModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)
      at Loader.requireModule (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:899:12)
      at Loader.requireModuleOrMock (node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:920:17)
      at Spec.<anonymous> (components/__tests__/Logs-test.js:30:12)

  - Expected: 0 toBe: 1
        at Spec.<anonymous> (components/__tests__/Logs-test.js:56:15)
1 test failed, 0 tests passed (1 total)
Run time: 6.854s
@hgezim
Copy link
Contributor Author

hgezim commented Sep 28, 2015

Setting preprocessCachingDisabled to true fixes the above issue. But that's a workaround.

@CoderK
Copy link

CoderK commented Oct 5, 2015

I have a same issue too.

@CoderK
Copy link

CoderK commented Oct 5, 2015

I was debugging awhile, haste_cache logic may be related to this issue.
When a cacheKey is generated in readAndPreprocessFileContent(filePath, config) function of utils.js, a different value is made every time.

A. First try
Filename : /Users/KimCoding/Workspace/PhotoMoa/src/sample/__tests__/helloworld-test.js
cacheKey : 754124e15ac50f241d7079bd992b0814

B. Second try
Filename : /Users/KimCoding/Workspace/PhotoMoa/src/sample/__tests__/helloworld-test.js
cacheKey : f57f35f2fd451dad8fe33658d2a4eda1

Because I'm using the babel-jest plugin, it is in the doubt.

@cpojer
Copy link
Member

cpojer commented Oct 5, 2015

Yeah I think the problem is that it stringifies the config object as well and the encoding isn't stable, ie. the keys in the config object are sorted randomly. I'm not sure why that would lead to problems however, it just leads to more work for the pre-processor. But yeah, this should be fixed.

@amasad
Copy link
Contributor

amasad commented Oct 6, 2015

fixed via 38a364f and 5039aad

@amasad amasad closed this as completed Oct 6, 2015
@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

4 participants