All Questions
Tagged with jasmine2.0 angular
28 questions
1
vote
1
answer
2k
views
How to write unit test case of ag agrid cellRenderer with return value in angular
TS:
columnDefs = [
{ headerName: 'columnone', field: 'one', width: 120, sortable: true,
cellRenderer: (data) => {
return this.limitCommonUtil.numberFormatter(data?.data?.upperAmount);
...
1
vote
1
answer
606
views
How can I test that a function was called inside an if statement in jasmine-karma
I'm creating an Angular app and I'm learning unit test and I want to test certain method, but I can't manage to test that the function enters in the if statement. I don't know how to force it. Could ...
0
votes
0
answers
168
views
Stub out component private method
Jasmine can be used to spy on private methods.
Can you use Jasmine to stub out a private method in an Angular component? The pattern I am using spies on specific providers - not components.
Can you ...
1
vote
1
answer
3k
views
Failed: Invalid provider for the NgModule 'DynamicTestModule' - only instances of Provider and Type are allowed, got: [[object Object]?]
So there's this delightful error that's the very definition of annoying
this is the describe method:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MapMap ],
imports: ...
1
vote
1
answer
1k
views
Angular karma can't capture browser after updating angular 9 to 10
I followed the guide on the angular update giude to update my project from version 9 to 10. My project and my karma tests ran perfectly fine with angular 9. The update changed the TypeScript version ...
2
votes
0
answers
505
views
How to test Observable subscribe callback using jasmine?
I have an Angular9, Angular Material table similar to the ones in the docs.
https://material.angular.io/components/table/examples
The difference in my case is that I implemented a constructor in the ...
1
vote
1
answer
1k
views
Webpack directory appended at error after migrating to Angular9
I've recently upgraded my projet from angular 7 to angular 9.
When I run the tests (ng test), I always get http://localhost:9876/_karma_webpack_/ appendend to the error, hence in visual studio code, ...
1
vote
2
answers
2k
views
When to use createSpy, createSpyObject and spyOn?
I have learned recently that spyOn cannot be used with external dependencies and can only be used with System Under Test.
But I have some questions regarding why it cant be used and I came up with ...
0
votes
1
answer
1k
views
Testing angular auth guard redirection
I have an Angular authenticated guard
@Injectable({
providedIn: 'root'
})
export class AuthenticatedGuard implements CanActivate, CanActivateChild {
constructor(@Inject('Window') private ...
2
votes
1
answer
2k
views
How to test whether an Angular mat-nav-list contains an element?
I'd like to check whether an Angular mat-nav-list contains an element.
I'm able to select it with fixture.debugElement.query(By.css('.items')), but I'm not sure how to check whether it contains ...
0
votes
0
answers
273
views
Angular 6 and Karma/Jasmine issue - No Angular CLI
My app is currently on Angular 6.1.9, Karma 2.0.0 and Jasmine 2.4.1. After Angular 6 upgrade, npm test fails. Chrome browser opens to indicate that Karma is connected. But I see EXECUTED 0 OF 0 TEST ...
2
votes
0
answers
219
views
Angular 5 / Jasmine 2 test setTimeout function only once
my problem is that i have this fonction :
loopPingAPI() {
this.pingAPI().then(
success => {
this.setConnected(true);
this.stopPingAPI();
...
0
votes
1
answer
1k
views
Mock a provider class to return response and handle promise - Unit Testing with Jasmine and Karma with Ionic 3
Am a newbie in Unit Testing. I started to write Unit Testing for my Ionic 3 Application using Karma and Jasmine. I followed blogs to get the configurations set and successfully tested the ...
2
votes
1
answer
1k
views
NgModel binding doesn't work inside <form> for Jasmine test
In my Angular 5.2.0 project, I have the following structure:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } ...
0
votes
2
answers
1k
views
Angular 6 - mock authState - valueChanges of undefined
I have a service with a property and a getter. The property is set in the service constructor like this:
public readonly usersMetaData: Observable<User | null>;
constructor(private afAuth: ...
0
votes
1
answer
3k
views
Angular 6 testing - Jasmine - mock chained promises
Ive got a method register() in my service which I want to test. My assert is that an another method from a injected service is called. Lets have a deeper look into my code:
Service
export class ...
6
votes
2
answers
11k
views
Angular testing mock subscribed property
I have a service with 2 properties:
Service
...
public usernameAnnounced;
private username: Subject<string> = new Subject<string>();
constructor() {
super();
this....
3
votes
1
answer
3k
views
Jasmine SpyObj doesn't return mocked object
I'm trying to test the following service.
@Injectable()
export class TranslationService {
language = 'NL';
constructor(contextService: ContextService) {
let context = contextService....
2
votes
2
answers
3k
views
Protractor afterEach extract browser.manage().logs() to a helper function
My overall goal is to extract the browser.manage().logs() to a helper function. I'm stepping towards this goal by including the browser.manage().logs() functionality inside the afterEach call inside ...
0
votes
1
answer
157
views
Promises are not waiting resolve in jasmineDone
I am trying to post the result on testrail portal but this thing doesn't seem to be working. I am using this plugin https://www.npmjs.com/package/testrail-api
and trying to do it in jasmine custom ...
1
vote
3
answers
2k
views
Protractor failed to start test with firefox
I can not start the test with protractor on firefox version 56.0.1.
my protractor version is 5.1.2
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
]...
10
votes
2
answers
10k
views
How to trigger document level events from a jasmine test Angular 2/4
According to the Angular Testing documentation, to trigger the events from the tests, we use the triggerEventHandler() method on the debug element. This method takes the event name and the object. Now,...
30
votes
4
answers
49k
views
Spec has no expectations - Jasmine testing the callback function
I have a method which is being called using a d3 timer. Whenever the method is called, the method emits an object with a couple of values.
One of the values increases over time. I would like to write ...
4
votes
1
answer
2k
views
How to trigger Ionic's Platform.ready in testing?
I'm building my first Ionic app and trying hard to follow TDD. I've hit a stumbling block with the Platform.ready promise that Ionic provides. I cannot, for the life of me, figure out how to trigger ...
2
votes
0
answers
252
views
jit__object_Object_26 is not a constructor
I have problem testing my AuthenticationService class and the message is very confusing. I had to provide AuthenticationConfigService, but I have this error now when running tests: ...
0
votes
0
answers
800
views
Karma-Jasmine setup for Angular project
I have an angular(currently @4.0.0) project for which I want to introduce Unit Testing using Karma and Jasmine.
I have set up the appropriate karma.conf.js, spec-bundle.js and package.json. But when ...
1
vote
0
answers
477
views
Protractor tests are timing out due to async call back not invoked with angular 2 App SPA
We are building SPA with angular cli, We are to verify controls on log in page (username,password and login) but after login/redirect to another component i am getting error message
"Error: ...
1
vote
1
answer
376
views
Protractor4.0.9 / jasmine2 / Chrome 54+: Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
I know this question have been solved but it doesn't work for me.
I upgrade to protractor4.0.9/Jasmine2, chromedriver 2.25, Chrome54.
A simple test like this is failing:
describe('Test', () => {
...