Olá. Estou escrevendo testes unitários usando JEST e estou enfrantando o seguinte problema: Jest: Coverage data for globals was not found.
Que estourou o seguinte:
pm ERR! code ELIFECYCLE
error 08-Nov-2023 09:46:48 npm ERR! errno 1
error 08-Nov-2023 09:46:48 npm ERR! my-app@0.0.0-x test: `jest`
error 08-Nov-2023 09:46:48 npm ERR! Exit status 1
error 08-Nov-2023 09:46:48 npm ERR!
error 08-Nov-2023 09:46:48 npm ERR! Failed at themy-appt@0.0.0-x test script.
error 08-Nov-2023 09:46:48 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Meu package.json:
"jest": {
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"<rootDir>/src/setup.jest.ts"
],
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/dist/"
],
"collectCoverage": true,
"collectCoverageFrom": [
"./src/**"
],
"coveragePathIgnorePatterns": [
"node_modules",
"test-config",
"interfaces",
"jestGlobalMocks.ts",
".module.ts",
"<rootDir>/src/app/main.ts",
".mock.ts",
"src/environments",
"src/index.html",
"src/main.ts",
"src/polyfills.ts"
],
"coverageThreshold": {
"global": {
"lines": 70,
"statements": 70
},
"globals": {
"ts-jest": {
"tsConfig": "<rootDir>/tsconfig.sepc.json",
"stringifyContentPathRegex": "\\.html$"
}
}
}
}
Angular.json:
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"coverage": true,
"codeCoverageExclude": [
"e2e/**",
"mock/**",
"**/*config.js",
"**/*conf.js",
"**/environments/*.ts",
"**/*.spec.ts",
"**/main.ts",
"**/polyfills.ts",
" **/index.html",
"**/*app.module.ts",
"**/*.spec.ts, **/*.ts",
"src/test/*"
],
"no-cache": [
"true"
],
"tsConfig": "tsconfig.spec.json",
"testMatch": [
"**/__test__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"polyfills": [
"src/polyfills.ts"
],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
Não encontrei nada sobre o assunto. Poderiam me ajudar?