Having encountered an issue with Jest testing in a Nuxt/Vue v2 project, I found that after making some changes, the tests were no longer running. The unit tests were either passing or failing initially, but suddenly stopped running altogether.
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Test Suites: 0 of 10 total
Tests: 0 total
Snapshots: 0 total
Time: 3.454 s, estimated 10 s
Ran all test suites.
Despite trying to bring back the previous code and stashing the changes before rerunning the tests, none of the test suites would execute. Even creating an empty test suite did not trigger any errors such as 'your test suite must contain at least one test', across both the tests/unit
directory and other folders.
I usually maintain careful commit practices, but it's possible that I made a mistake along the way. Perhaps there was an issue with the dependency tree, like missing a crucial dependency in package.json (I even reinstalled node_modules from scratch at one point). It could also be a potential dependency mismatch that was previously unnoticed...
What might be causing this problem? How can I troubleshoot this situation effectively given my prior experience with Mocha/Chai?
Below are my configuration settings:
jest.config.js
module.exports = {
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/$1",
"^~/(.*)$": "<rootDir>/$1",
"^vue$": "vue/dist/vue.common.js",
},
moduleFileExtensions: ["ts", "js", "vue", "json"],
transform: {
"^.+\\.ts$": "ts-jest",
"^.+\\.js$": "babel-jest",
".*\\.(vue)$": "vue-jest",
},
collectCoverage: true,
collectCoverageFrom: [
"<rootDir>/some-dir/**/*.(js|ts)",
],
testEnvironment: "jsdom",
testMatch: ["**/*.spec.(js|jsx|ts|tsx)", "**/*.test.(js|jsx|ts|tsx)"],
runner: "groups",
};
package.json
"scripts": {
…
"test:unit": "jest"
},
"dependencies": {
…
"core-js": "^2.6.12",
"nuxt": "^2.15.8",
"path-to-regexp": "^6.2.1",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"webpack": "^4.46.0"
},
"devDependencies": {
…
"@nuxt/types": "^2.15.8",
"@nuxt/typescript-build": "^2.1.0",
"@nuxtjs/device": "^2.1.0",
"@vue/test-utils": "^1.3.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^27.4.4",
"jest": "^27.4.4",
"jest-runner-groups": "^2.2.0",
"ts-jest": "^27.1.1",
"vue-jest": "^3.0.4"
}
}