Comments (11)
Looks like jest-preset-angular is using deep imports, instead of consuming the “public” entry-points
IE
jest-preset-angular/setup-jest.mjs
Line 1 in 65a848a
Instead of something like;
import 'zone.js/testing';
That being said, it’s a bit unclear how the zone-testing-bundle
should be consumed.
I think as an interim for v0.13.x we could re-allow deep imports and remove them in v0.14.x.
//cc @JiaLiPassion.
from jest-preset-angular.
zone.js
version 0.13.3
has been just released which should get around this issue.
Deep imports will eventually no longer be allowed from zone.js
version 0.14.0
.
The proper way to use zone testing is the following:
import "zone.js";
import "zone.js/testing";
from jest-preset-angular.
It's still an issue with the latest version of Angular (17.0.2), all of our tests are broken as well after upgrading. This is our following package.json
:
"dependencies": {
"@angular/animations": "~17.0.2",
"@angular/common": "~17.0.2",
"@angular/compiler": "~17.0.2",
"@angular/core": "~17.0.2",
"@angular/forms": "~17.0.2",
"@angular/localize": "~17.0.2",
"@angular/platform-browser": "~17.0.2",
"@angular/platform-browser-dynamic": "~17.0.2",
"@angular/router": "~17.0.2",
"@angular/service-worker": "~17.0.2",
"@ngrx/effects": "~16.3.0",
"@ngrx/store": "~16.3.0",
"rxjs": "~7.8.1",
"tslib": "~2.6.1",
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-builders/jest": "~16.0.0",
"@angular-devkit/build-angular": "~17.0.0",
"@angular-eslint/builder": "~17.0.1",
"@angular-eslint/eslint-plugin": "~17.0.1",
"@angular-eslint/eslint-plugin-template": "~17.0.1",
"@angular-eslint/schematics": "~17.0.1",
"@angular-eslint/template-parser": "~17.0.1",
"@angular/cli": "~17.0.0",
"@angular/compiler-cli": "~17.0.2",
"@types/jest": "~29.5.3",
"jest": "~29.6.2",
"jest-canvas-mock": "~2.5.2",
"jest-preset-angular": "~13.1.3",
"typescript": "~5.2.2",
}
And our angular.json
configuration:
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"tsConfig": "tsconfig.spec.json",
"configPath": "jest.config.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
},
FAIL src/app/shared/components/features/search/components/search-companies/components/search-companies-by-id/pipe/search-companies-by-id-placeholder.pipe.spec.ts
● Test suite failed to run
Cannot find module 'zone.js/bundles/zone-testing-bundle.umd' from 'node_modules/@angular-builders/jest/node_modules/jest-preset-angular/setup-jest.js'
Require stack:
node_modules/@angular-builders/jest/node_modules/jest-preset-angular/setup-jest.js
node_modules/@angular-builders/jest/dist/jest-config/setup.js
from jest-preset-angular.
from jest-preset-angular.
indeed the temp fix seems to work now, but I guess it's probably better to keep this issue open until a proper fix is implemented. Thanks for the info and quick turnaround about the Angular upstream :)
from jest-preset-angular.
updating to the latest version (13.1.4) seem to have solved the issue for me.
from jest-preset-angular.
Update package "@angular-builders/jest": "^17.0.0"
solve the problem.
from jest-preset-angular.
I have the same error, everything was working fine last night, and now all of my tests are broken https://github.com/teambit/envs-health-status/actions/runs/6153094762/job/16696392467
from jest-preset-angular.
zone.js/bundles/zone-testing-bundle.umd
has been renamed zone.js/bundles/zone-testing.umd
in the last package
from jest-preset-angular.
Also occurs for new angular builders:
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"tsConfig": "tsconfig.spec.json",
"polyfills": ["zone.js", "zone.js/testing"]
}
}
fixed by enforcing zone.js
version 0.13.1
from jest-preset-angular.
Since Angular v17 will require Zone.js version 0.14.x or later, this is still an issue?
from jest-preset-angular.
Related Issues (20)
- [Feature]: Support Angular 16 HOT 5
- Unable to run tests [Bug]: HOT 1
- Angular 17 Support
- [Feature]: Angular 17 Support HOT 2
- [Bug]: ProxyZone not found when using jest functions imported from @jest/globals HOT 1
- [Bug]: Could not parse CSS stylesheet HOT 11
- [Bug]: jest-preset-angular 13.1.4 - `spyOn` no longer works for functions imported with `import * as` HOT 1
- [Feature]: Angular 17 support HOT 5
- [Bug]: Cannot read properties of undefined (reading 'each') of zone-testing HOT 3
- [Bug]: Drop support Angular versions
- [Bug]: Input signals in components cause tests to error out (Angular v17.1.0) HOT 8
- [Bug]: It is not work After config useESM: true HOT 3
- [Feature]: Support viewChild query from 17.2 HOT 4
- [Feature]: Support for contentChild signal functions HOT 1
- Unexpected tokenyntaxError: Unexpected token '??=' at wrapSafe (internal/modules/cjs/loader.js:1001:16) HOT 6
- [Bug]: Import in component is undefined under test HOT 2
- [Bug]: jest-global-mocks should set the value of `CSS` to undefined and not null
- [Feature]: Package Updation HOT 1
- [Bug]: input.required signals cannot be set in TestBed HOT 5
- [Feature]: Support `outputFromObservable` interop function for `output`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-preset-angular.