All Questions
Tagged with angular-cli unit-testing
69 questions
0
votes
0
answers
279
views
Error: This command is not available when running the Angular CLI outside a workspace when running ng test
I am having this issue when trying to run ng test for a component that I've created.
I tried opening in integrated terminal, open a cmd terminal and try there and other things to but I always get that ...
1
vote
1
answer
219
views
TypeError: this.canvasContainer is undefined in unit test Angular
I want to test my service in angular with karma and jasmine, I begin with unit tests and I don't found any solution for my case or because I don't know how I can fix the issue. I always have a problem ...
23
votes
1
answer
15k
views
log4js-node-DEP0004 - Deprecation warning in Angular 12 karma unit tests
I'm getting the following deprecation warning when running unit tests in a brand new Angular 12 application:
(node:14940) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due ...
2
votes
1
answer
2k
views
Unable to run a single/specific .spec.ts file through angular cli using ng test --include option
I am trying to run a single .spec file in my ionic/angular project by using following command:
ng test
--include="/home/usama/Documents/Vanguard-Office/PrimeTutor/PrimeTutorClient/src/app/login/...
0
votes
2
answers
5k
views
fixture.detectchanges() method resulting in test case to fail
I am unit testing my component using Karma and jasmine. fixture.detechChanges() should be use for every test in order to detect the changes. But this method is making the test case to fail and giving ...
6
votes
0
answers
2k
views
Cannot set base providers error after Angular v9 upgrade using 'ng test'
I've got all of my unit tests updated and passing after an upgrade from v8 to v9. However, now I'm getting the following error:
Cannot set base providers because it has already been called
Research ...
1
vote
0
answers
363
views
Can the Angular CLI be configured to generate Unit tests with a different extension?
I am currently working on an Angular 9 project which uses Angular CLI v9.1.3. By default the Angular CLI v9 (including lower and higher versions - as far as I know) is configured to generate unit test ...
1
vote
1
answer
640
views
how do I test ng-add schematics
I decided to add an ng-add schematic to my library, since there are additional setup steps when installing it past running npm/yarn install. This way, users will be able to run ng add @myorg/mylib and ...
3
votes
1
answer
867
views
How to load test resources
I'm testing Angular 9. I read all the documentation and created a simple website that needs to parse some text file the user can drag and drop. I have a service for the parsing part and now I'm trying ...
6
votes
1
answer
2k
views
Karma tests which run to successful completion in Angular 7 (Karma 2.0.4) fail after Angular 8 (Karma 4.1.0) upgrade
We have a suite of ~1100 units running in ’ng test’ which currently run to completion in ~4 minutes with no failures in Angular 7.2.5 and fail to run to completion with random failures, slowdown, and ...
1
vote
1
answer
280
views
An error was thrown in afterAll [object ErrorEvent] when using path to module in require.context()
I am getting a really strange error in my Angular app when I execute ng test with this config:
const context: any = require.context('./', true, /\.spec\.ts$/); // all modules
const contextModule1: ...
12
votes
1
answer
9k
views
What is different between fixture.debugElement.componentInstance and fixture.nativeElement?
In this sample test file I saw two different syntax
one is const app = fixture.debugElement.componentInstance; and another is const compiled = fixture.nativeElement; I don't know what is different ...
2
votes
2
answers
289
views
Unit testing Nativescript application logic on a browser
I am trying to set up unit testing for a Nativescript application, run by ng test on a browser. The problem is that whenever there is a tns-core-modules or another plugin import, the module cannot be ...
3
votes
4
answers
3k
views
Angular how not to import all the dependencies in component unit tests each time
I have a working app(when run ng serve all works fine)
however, when I run ng test compiler complains about not recognizing directives/properties such as Can't bind to 'formControl' since it isn't a ...
2
votes
0
answers
1k
views
"Cannot find namespace" only during ng test
I'm assuming/feel sure that I'm just missing something very minor. There is an adal.ts file that contains an adal namespace. (this is local to my project) For some reason this file doesn't ...