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
Tests fail to run in watch mode #8534
Comments
I've also just noticed that I can get watch mode to work in the following situation:
|
I've made a repo in which you can reproduce this issue: |
I've tested on 2x macOS devices and 1x windows device and |
Our whole team has the same issue. Tests are running ok when we run all tests with Error:
My module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/filePathMock.js',
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',
testPathIgnorePatterns: ['node_modules', 'e2e'],
moduleFileExtensions: [
'ts',
'tsx',
'js',
'json',
],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
'\\.svg\\?inline$': '<rootDir>/__mocks__/svgMockModule.js',
'(.*)\\.svg\\?external$': '$1.svg',
'^~(\\\\|/)(.*)$': '<rootDir>/src/$2',
},
setupFilesAfterEnv: ['<rootDir>/jest.enzyme.config.ts'],
setupFiles: [
'<rootDir>/__mocks__/shims.js',
'<rootDir>/jest.enzyme.config.ts',
'<rootDir>/__mocks__/webpackDefines.js',
'<rootDir>/__mocks__/localstorage.js',
],
cacheDirectory: '<rootDir>/.jest-cache',
coveragePathIgnorePatterns: [
'/*.svg',
'/node_modules/',
],
snapshotSerializers: [
'enzyme-to-json/serializer',
],
watchPathIgnorePatterns: ['backstop_data'],
reporters: ['default', 'jest-html-reporter', 'jest-junit'],
coverageReporters: ['cobertura', 'html'],
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig-ts-jest.json',
},
},
}; Jest version: 23.6.0 and 24.8.0 |
@NileDaley @jeysal I couldn't reproduce the error with the repo from #8534 (comment) using
|
Alright, I can reproduce that. I believe the reason why this occurs is that |
@jeysal Isn't |
Jest does not use tsc for TS support, only ts-jest does. |
Having a similar error message after deleting a source file and commenting everywhere the source file is referenced. While running jest in watch mode, this error is produced, however jest without watch, runs successfully. Somehow jest caches and wanted to imported the deleted source file ? |
I have found in jest watch mode if I'm changing branches sometimes it thinks something is there that isn't there anymore, and throws a similar error message. I sometimes just have to delete node modules and re-install to get it to work. |
This indeed solved it @jeysal ! |
hi, I came from an issue in thing.ts contains:
thing.test.ts contains:
I wonder if this is something |
Guys, I am not sure if that issue stills haunting someone, but in my case, the issue was the existence of the If the modules described there are somehow different from your current file structure, there is a chance to see this annoying issue. Deleting the forenamed folder did the trick and made the watch mode work great as usual. |
+1 this bug. We are currently running into it. |
Having this failure, too. :( So annoying. Tests pass when running If I add It fails:
Tests break if I add "d.ts" as a module extension! Using --watchAll works. Package versions:
jest config:
|
Very strange failure trying to use a shim on JSON for BigInt. I put this shim in setupFiles: Running just Running This blog posts describes almost exactly the same issue in some detail: https://realonetech.wordpress.com/2021/03/24/jest-custom-matcher-in-typescript/ |
@SHaTRO , +1 on your report, I faced exactly the same issue you pointed out. |
I was also having the problem, where --watchAll wasn’t refiring on changes to files. The following Jest config it. Hope it helps you all or someone at least!
|
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🐛 Bug Report
My tests run just fine when using the
jest
command. However, as soon as I runjest --watch
I get the following error.Here's a
tree
of mysrc/renderer/types
folder:My
jest.config.js
file contains the following:And my tsconfig.json file looks like this:
Jest version: "^24.5.0",
ts-jest version: "^24.0.0",
typescript version: "^3.4.5"
The text was updated successfully, but these errors were encountered: