-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Jasmine's clock mocks can't be used in library specs #14432
Comments
any update for the fix? |
I had a look at this and the problem is indeed that Jasmine is loaded prior to
import 'zone.js/dist/zone';
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": "projects/asdasd/src/polyfills.ts",
"main": "projects/asdasd/src/test.ts",
"tsConfig": "projects/asdasd/tsconfig.spec.json",
"karmaConfig": "projects/asdasd/karma.conf.js"
}
}, |
As far as I can tell, this is still an issue. Just a couple of notes on the suggested workarounds:
|
this is still an issue with Angular 14, and the workaround doesnt work for me :( |
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (angular#14432) which was caused by the missing polyfills file in the library test setup. Closes angular#14432
With this change we drop the `polyfills.ts` from new application projects and add the polyfills directly in the `angular.json`. This is possible as now the `polyfills` option accept an array of module specifiers. This change also fixes another open issue (#14432) which was caused by the missing polyfills file in the library test setup. Closes #14432
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Not sure to be honest, but it works if the sample spec is part of the application in the workspace.
Description
Attempting to use Jasmine's clock mocks inside tests of CLI generated libraries throws an error saying 'Jasmine Clock was unable to install over custom global timer functions.'. It seems Jasmine is imported before Zone.js and therefore detects that the global timing functions, such as setTimeout, were changed afterwoods.
The issue is similar to #11626.
🔬 Minimal Reproduction
🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
Based on the fix for #11626, adding a (e.g.)
test-pollyfill.ts
to the library source and moving the zone.js import from the library'stest.ts
file into the test-pollyfill.ts file, then configuring the test architecture of the library's project inangular.json
to use the file as the 'pollyFills' option seems to be a possible workaround for now.The text was updated successfully, but these errors were encountered: