为什么 jest 寻找不再存在的测试文件?

And*_*orn 4 javascript testing reactjs jestjs

在创建新测试时,我收到此错误:

Determining test suites to run...Error: ENOENT: no such file or directory, stat '/home/andrew/Documents/wise-fox/The-App/src/tests/components/AlertsComponent/AlertsPages/PromoPage3.test.js'
    at Object.fs.statSync (fs.js:948:11)
    at Object.statSync (/home/andrew/Documents/wise-fox/The-App/node_modules/graceful-fs/polyfills.js:297:22)
    at fileSize (/home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/test_sequencer.js:71:73)
    at tests.sort (/home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/test_sequencer.js:91:34)
    at Array.sort (native)
    at TestSequencer.sort (/home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/test_sequencer.js:77:18)
    at /home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/run_jest.js:148:26
    at Generator.next (<anonymous>)
    at step (/home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/run_jest.js:27:377)
    at /home/andrew/Documents/wise-fox/The-App/node_modules/jest/node_modules/jest-cli/build/run_jest.js:27:537
Run Code Online (Sandbox Code Playgroud)

该错误正在尝试查找不再存在的测试文件。我复制了一些测试,然后修改了文件的名称以及里面的测试以适应新文件。

以前,jest 只是意识到某些测试文件已经消失(因为重命名),但在这种情况下,jest 认为这些文件仍然存在。我不知道为什么,也不知道如何解决。

框架:React 16 操作系统:Linux 基本操作系统

tn4*_*xah 16

对我来说,这不是快照问题,而是缓存问题。跑步

jest --clearCache
Run Code Online (Sandbox Code Playgroud)

摆脱它。


And*_*orn 6

啊,这和过时的快照文件有关。我手动删除了它们,测试运行得很好

  • 实际上,“提及”快照文件/目录通常存储的位置会有所帮助。 (2认同)