Proper message when angular test.ts has invalid order instead of "TypeError: Cannot read property 'assertPresent' of undefined"
See original GitHub issueAfter I enabled ts-lint autofix with import sorting I got error in my tests “TypeError: Cannot read property ‘assertPresent’ of undefined”
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import { getTestBed } from '@angular/core/testing';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import 'zone.js/dist/zone-testing';
declare const require: any;
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
const context = require.context('./', true, /\.spec\.ts$/);
context.keys().map(context);
After that i found https://github.com/angular/angular/issues/11317#issuecomment-419122951 which solved my issue but I am not one who have this problem
I would expect to see proper message that my “import ‘zone.js/dist/zone-testing’;” is wrong.
I also submitted feature-request to angular-cli but it was rejected. Such issues just make people to dislike angular while I want them to love it 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Testing | Cannot read property 'assertPresent' of undefined at ...
PS: I am using VS Code, which now automatically sorts imports upon file save and thus changes my custom order of imports, which...
Read more >Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >TestBed - Angular
Configures and initializes environment for unit testing and provides methods for creating components and services in unit tests.
Read more >How To Use waitForAsync and fakeAsync with Angular Testing
Learn how to test asynchronous code more easily using the async ... When the button is clicked, the title property is set using...
Read more >How to fix "Cannot read properties of undefined (reading ...
I don't have a good answer for this one... I'm getting an error like this from an Angular unit tests: TypeError: Cannot read...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the reason is
tslint
just change theimport order
. you need toimport 'zone.js/dist/zone-testing'
in the first line.@vovikdrg, oh, you are right, I will change this message, thanks!