Skip to main content
Filter by
Sorted by
Tagged with
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); ...
Ashwini's user avatar
  • 305
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 ...
Julio Rodríguez's user avatar
1 vote
0 answers
46 views

How to pass global variable into one test suite that has 3 test cases

I am trying to verify the delete functionality works as expected, so I am at the same test case creating a post and get its postId then delete it and lastly verify the postId does not found . it('...
nadiakhouri's user avatar
-1 votes
1 answer
76 views

Jasmine - JavaScript: How to check array response by validating one of the array returned data?

What if I want to validate a result from an array response! Response: ({ id: '612d56952ca01806398dac1f', lastUpdated: '2021-08-30T22:07:17.099Z', userToken: 'public', data: Object({ createdOn: '2021-...
nadiakhouri's user avatar
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 ...
Hoppe's user avatar
  • 6,785
1 vote
0 answers
554 views

Jasmine , Karma - Ignore ids from result object while comparison using toEqual

I am writing some test cases for a function that takes in an input and provides a modified output object. My mock response is :- mockResponse = { "id":1, "value":23, ...
Veryon890's user avatar
  • 390
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: ...
Grant Solomons's user avatar
0 votes
1 answer
93 views

protractor-jasmine2-screenshot-reporter blank screenshot

Protractor config file have 2 reporting custom report for logging and other one is protractor- jasmine2-screenshot-reporter. Screenshot png is generate but blank white screen only dispalyed. Below ...
ardjavatake2selenium's user avatar
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 ...
Nils Walker's user avatar
1 vote
1 answer
466 views

Protractor exited with error code 100 when run config.js

A few days ago, my protractor was working fine. But yesterday when I tried to run the same tests, I got: E/launcher - Error: Error: Cannot find module 'jasmine-reporters' Require stack: - D:\Repos\POS\...
IBrito's user avatar
  • 69
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 ...
Error Check's user avatar
0 votes
1 answer
61 views

AngularJS - Jasmine - Cannot test Service in Controller callback function

I need help with Jasmine test. I have this controller with a simple service: angular.module('${project.name}') .controller('MyControllerCtrl', function ($scope, InvocationService) { $scope.vm = {...
Carlos Mazzoli's user avatar
0 votes
2 answers
60 views

Protractor POM method is not recognizing

spec.js describe('Testing an animal adoption flow using page object', function() { beforeEach(function() { browser.get('http://www.thetestroom.com/jswebapp/index.html'); }); ...
Vijay's user avatar
  • 1
0 votes
0 answers
138 views

Function to left rotate a given array item n position to left - JavaScript

I'm doing some exercises on JavaScript and I came into a question that asks to rotate arrays item to the left with a given n rotation steps. The exercises are tested with Jasmine. Tried several method ...
esQmo_'s user avatar
  • 1,709
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, ...
JFPicard's user avatar
  • 5,158
0 votes
0 answers
148 views

How to configure jasmine to logout message when expect was failed

I have a Jasmine check point to check the expect error message, and when the check point was failed, I only get the following message: Error: Failed expectation Question is, is there any ...
luffy's user avatar
  • 11
-1 votes
1 answer
873 views

Jasmine - undefined is not a constructor

export default { retrieve() {...}, process: { getData(source) { return this.retrieve({id: source.id}) .then((reply) => { source.reply = reply; ...
CodeBreaker's user avatar
0 votes
2 answers
1k views

How test steps could be displayed for a test case in allure report for jasmine protractor framework

How can i show the test steps in allure report for protractorTest steps are not displaying as it displays for java language. Even the allure report official documentation does not show any code ...
Manp's user avatar
  • 1
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 ...
Linta Sheelkumar's user avatar
0 votes
0 answers
329 views

How to pass a token for jasmine requests

I implemented my tests in an application without authentication, but when it was implemented my tests stopped working. I have an API to generate a token, how can I put this token in my services inside ...
Guilherme Prado's user avatar
0 votes
1 answer
3k views

How can i test a function that return a promise or reject - Jasmine and Karma

I need to cover 100% of the tests of a function, it returns a return new Promise<boolean>((resolve, reject) this is the full function. saveData(): Promise < boolean > { return new ...
Guilherme Prado's user avatar
0 votes
1 answer
551 views

How can i coverage a promise response with Jasmine and Karma

I have a function that returns and treats a promise, I need to cover the return that is inside then but I don't know how I can do this, I'm currently trying as follows: confirmRemoveUser(user: ...
Guilherme Prado's user avatar
0 votes
1 answer
806 views

How to cover all lines of a function with jasmine-karma

How can I cover all lines of the function below using jasmine? addUser(): void { if (this.validateNewUser()) { this.newUser._Job = this.selectedJob; this.newUser.PositionId = ...
Guilherme Prado's user avatar
-2 votes
1 answer
51 views

i have problem with protractor when i am trying to execute the test cases in Microsoft edge browser. i am getting error

i am getting this error when i am trying to execute test cases in Microsoft edge browser
Dileep Reddy's user avatar
0 votes
0 answers
121 views

Protractor (5.4.2) hangs when running shardTestFiles: true

When running protractor without sharding, it runs just fine, the tests are passing or failing, and in the end the webdriver / protractor execution stops. When trying to run protractor with sharding, ...
Maxime Hussenet's user avatar
1 vote
3 answers
121 views

Chrome in Mac is not starting in maximised state even after trying with '--start-fullscreen' in args

Need my chrome to start in maximised state every time my protractor suite initialises Have already tried updating the chrome drive with webdriver-manager update. Still no go I'm using this in my ...
Shubh Ambaly's user avatar
0 votes
1 answer
209 views

Mock rxjs debounce in Jasmine 2

I have the following observable function: $scope.$createObservableFunction("getInformation") .debounce(300) .flatMapLatest(function() { ...
Sam's user avatar
  • 7,038
0 votes
2 answers
1k views

Spy on a method of an object created dynamically during test execution

I need to spyOn a method of an object created dynamically inside another method So consider the following: public doStuff = () => { const myThing = new MyThing(); myThing.doSomethingElse(...
mindparse's user avatar
  • 7,185
6 votes
1 answer
1k views

How to ignore Jasmine promises when "no-floating-promises" in tslint is true

Is there a way to have "no-floating-promises" turned on but let it ignore Jasmine promises like "toEqual", "toBe", etc.? I want to use it, but it complains about my expect statements all over the ...
Trevor Murphy's user avatar
0 votes
0 answers
126 views

Spy Alert called after expect statement

I am trying to test a piece of code where alert is popped if you try to use back button of browser. var msg = ''; spyOn(window, 'alert').and.callFake((arg) => { msg = 'Alert Was Called'; ...
Z.Amir's user avatar
  • 195
0 votes
0 answers
788 views

utils is not defined and Expected undefined to be function

"I'm trying to cover my default function through to jasmine. But facing issue with dependency files where jasmine is unable to took reference of those dependency. Getting 1 error utils is not defined ...
macdis's user avatar
  • 11
0 votes
2 answers
798 views

Cleandestination in jasmine html reporter is not working

I am using the following code to generate HTML report for e2e testing in protractor. jasmine.getEnv().addReporter(new HtmlReporter({ baseDirectory: './e2e/e2e_coverage/', savePath: './e2e/...
sindhu kommoju's user avatar
10 votes
2 answers
38k views

How to fix function has already been spied on error in Jasmine

I have 3 tests, each testing various methods. it('test function1', function() { spyOn(document, 'getElementById'); // ... some code to test function1 expect(document.getElementById)....
Mumzee's user avatar
  • 769
-1 votes
1 answer
54 views

Can we execute one 'it' block from a file on different browsers while other test cases are running on another browser?

In a file I have 5 'it' blocks under single describe block, is a way where I can execute 1 test case always on Chrome browser while executing other 4 on Firefox or IE?
seleniumuser123's user avatar
3 votes
1 answer
5k views

WebDriverError: No active session with ID

My tests fail when am running them on TFS with the below error WebDriverError: No active session with ID Failed: No active session with ID The same tests pass locally - it was working fine until ...
Adam reed's user avatar
-1 votes
1 answer
154 views

Do spies in Jasmine actually call the function they are spying on?

I want to know how the "spyOn" function works internally. I read that the 'spyOn' function internally replaces the implementation of the function being spied on. Does it keep the old functionality? ...
Adam Forward's user avatar
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 ...
Chris Barr's user avatar
  • 33.8k
0 votes
0 answers
33 views

How to manage protractor to wait for a angular page load where the angular SPA is integrated into another angular app as iFrame

While executing e2e tests in protractor when we are using ignore.synchronization=true/ browser.waitforAngularEnabled(true) to handle waits is too slow when compared to browser.sleep(10000) to proceed ...
barat21's user avatar
  • 31
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 ...
saæ's user avatar
  • 183
1 vote
2 answers
2k views

Jasmine - Restart browser between tests (it blocks)

In our Protractor+Jasmine framework trying to restart browser between tests for different login user. As we have non-angular login page and after login its navigate to angular page. Following is my ...
Saagar's user avatar
  • 834
-2 votes
1 answer
273 views

Should Jasmine 'expectationFailedOutput' messages describe what was expected, or what happened?

Jasmine expect statements can produce worthless error messages like: Expected true to be false. To address this, matchers allow you to add a clarifying message as a second argument, ...
Mud's user avatar
  • 28.9k
1 vote
1 answer
2k views

JasmineJS + AngularJS: How to mock the delay inside Spy#callFake()

Let's assume I have a service function that returns me the current location. And the function has callbacks to return the location. We can easily mock the function like as follows. But I wanted to ...
Manoj Shrestha's user avatar
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 ...
user3344978's user avatar
0 votes
2 answers
441 views

how to test and resolve Controller data (.then function()) promise and get orginal Data in Jasmine2

I am testing a controller that uses a service that returns a promise. I need to resolve promise. I am using Jasmine 2. Here is Spec code beforeEach(inject(function ($controller, $...
Ajay.k's user avatar
  • 121
0 votes
1 answer
501 views

Says Jasmine spy is not being called, but I can see that its being called

I can't figure out why Jasmine is claiming that the function I'm spying on isn't being called, especially since it is logging in buildLinksObj when called through and not calling when I remove .and....
Gwater17's user avatar
  • 2,304
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(); ...
Stefan MARTEL's user avatar
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 ...
Joseph's user avatar
  • 1,080
2 votes
0 answers
808 views

Protractor - logout from page in afterAll() section

I have a lot of jasmine-based tests in different files, each of them defined in format, like describe(... { it(...) it(...) .... }) I need to perform a log out from the application after the ...
Stanislav Kharchenko's user avatar
0 votes
2 answers
558 views

Test fails with Winston logger implemention in protractor

Background: I'm using Jasmine2 as my test framework for Protractor and trying to implement a logger mechanism in the framework using winston package for better logging. Problem: Test fails with below ...
Ashish's user avatar
  • 191
3 votes
0 answers
895 views

Random number of jasmine tests fail when run together, but they pass individually?

I have around 450 assorted specs written in Jasmine (async & sync) in my codebase. Karma is the test runner which I use for running the tests on a headless chrome browser. Whenever I run the tests ...
ShellZero's user avatar
  • 4,633