angular-cli
angular-cli copied to clipboard
setup jest error
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
i have just update angular 15 to 16 and install "jest": "^29.5.0" and "@types/jest": "^29.5.1",
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
✘ [ERROR] Two output files share the same path but have different contents: layout.component.spec.mjs
✘ [ERROR] Two output files share the same path but have different contents: home.component.spec.mjs.map
✘ [ERROR] Two output files share the same path but have different contents: home.component.spec.mjs
● Validation Error:
Module <rootDir>/jest-global.mjs in the setupFilesAfterEnv option was not found.
<rootDir> is: /home/prabin/Desktop/technoFex/durapp/dist/test-out
Configuration Documentation:
https://jestjs.io/docs/configuration
Please provide the environment you discovered this bug in (run ng version)
"dependencies": {
"@angular/animations": "^16.0.1",
"@angular/cdk": "^16.0.0",
"@angular/common": "^16.0.1",
"@angular/compiler": "^16.0.1",
"@angular/core": "^16.0.1",
"@angular/forms": "^16.0.1",
"@angular/material": "^16.0.0",
"@angular/platform-browser": "^16.0.1",
"@angular/platform-browser-dynamic": "^16.0.1",
"@angular/router": "^16.0.1",
"cropperjs": "^1.5.13",
"eslint-plugin-jsdoc": "^44.2.2",
"flowbite": "^1.6.5",
"ng-tw": "^0.0.16",
"ngx-owl-carousel-o": "^15.0.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "^0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^16.0.1",
"@angular-eslint/builder": "16.0.1",
"@angular-eslint/eslint-plugin": "16.0.1",
"@angular-eslint/eslint-plugin-template": "16.0.1",
"@angular-eslint/schematics": "16.0.1",
"@angular-eslint/template-parser": "16.0.1",
"@angular/cli": "~16.0.1",
"@angular/compiler-cli": "^16.0.1",
"@types/jasmine": "~4.3.0",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"autoprefixer": "^10.4.14",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jasmine-core": "^4.6.0",
"jest": "^29.5.0",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"postcss": "^8.4.21",
"prettier": "^2.8.8",
"tailwindcss": "^3.2.2",
"typescript": "^5.0.4"
}
Anything else?
No response
Looks like two issues here:
- ESBuild detected output file conflict with
layout.component.spec.mjs,home.component.spec.mjs, andhome.component.spec.mjs.map(are there others? text looks cut off). Do you have multiple source files with these names? Maybehome.component.spec.tsandhome.component.spec.mts? - Angular CLI ignored this error and tried to run Jest anyways. If ESBuild failed first, we should abort the Jest run altogether.
This can happen when you have two .spec.ts files that have the same names in different folders. The jest builder is not respecting the folder nesting, and is flattening all the output .mjs files into the same outputPath.
I've made a repo to demonstrate the issue: https://github.com/cplummer-linq/ng16-jest-output-path
- Run 'ng test'. It should show these errors:
X [ERROR] Two output files share the same path but have different contents: same-name.spec.mjs.map
X [ERROR] Two output files share the same path but have different contents: same-name.spec.mjs - Rename one of the same-name-spec.ts files to a different name.
- Run 'ng test' again. It should run successfully.