Questions tagged [jasmine2.0]

Jasmine is an open source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

Jasmine is an open source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

197 questions
36
votes
3 answers

Getting "$digest already in progress" in async test with Jasmine 2.0

I know that calling $digest or $apply manually during a digest cycle will cause a "$digest already in progress" error but I have no idea why I am getting it here. This is a unit test for a service that wraps $http, the service is simple enough, it…
ivarni
  • 17,658
  • 17
  • 76
  • 92
35
votes
2 answers

Jasmine calls.length and callCount are undefined

I'm trying to test my chrome extension with Jasmine but I'm having trouble getting calls.length and callCount to behave as expected. Both cases return undefined. I've included a sample of the code and the spec. Here's the rest of the code if it…
Dru
  • 9,632
  • 13
  • 49
  • 68
30
votes
4 answers

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 a test to check whether the values are in the…
zelda
  • 753
  • 2
  • 8
  • 19
23
votes
2 answers

Reset call on Jasmine spy does not return

I'm using a Jasmine (2.2.0) spy to see if a certain callback is called. Test code: it('tests', function(done) { var spy = jasmine.createSpy('mySpy'); objectUnderTest.someFunction(spy).then(function() { expect(spy).toHaveBeenCalled(); …
Jorn
  • 20,612
  • 18
  • 79
  • 126
17
votes
2 answers

Jasmine test explorer not showing test cases(it blocks) list in jasmine test explorer in visual studio code

I am using Visual Studio code, Protractor, Typescript and Jasmine framework. I have spec test cases within "it" block. To see all the test cases or it blocks I have installed "Jasmine Test Explorer " and "Jasmine Explorer UI" but somehow test cases…
simond
  • 684
  • 1
  • 10
  • 36
15
votes
1 answer

How jasmine clock works?

I don't want to read code for hours to find the relevant part, but I am curious how jasmine implements its clock. The interesting thing with it is that it can test async code with sync testing code. AFAIK, with the current node.js, which supports…
inf3rno
  • 24,976
  • 11
  • 115
  • 197
13
votes
1 answer

Explain about async/ await in Protractor

I'm new to protractor. How does async/await in this function works? Can anybody explain it to me? it('TC_01 - Verify Home page title', async () => { await headerPage.waitForTitleContain('Homepage', 30000); await…
Dao Minh Dam
  • 373
  • 1
  • 2
  • 14
12
votes
4 answers

Protractor flakiness

I maintain a complex Angular (1.5.x) application that is being E2E tested using Protractor (2.5.x). I am experiencing a problem with this approach, which presents primarily in the way the tests seem flaky. Tests that worked perfectly well in one…
Jürgen Simon
  • 876
  • 1
  • 12
  • 35
11
votes
1 answer

Why is my HTML test report always one XML file behind?

This code in my protractor config file works perfectly... except that the html file creation in onComplete always uses the junitresults xml file from the previous test run, instead of the xml file created in the same config file's onPrepare…
10
votes
2 answers

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, this works if we are adding the events using…
Angela Roux
  • 473
  • 1
  • 5
  • 14
7
votes
2 answers

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).toHaveBeenCalled(); }); it('test function2',…
Mumzee
  • 719
  • 1
  • 11
  • 25
7
votes
3 answers

Protractor/Jasmine2 - async callback not invoked within specified timeout

I've struggled in problem with my e2e tests runs on selenium grid. Sometimes the tests are failed due to Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Tried to solve it somehow bo…
Michal
  • 563
  • 3
  • 14
  • 24
6
votes
2 answers

Is it possible to force Protractor to pass or skip a test with a message to the console?

I'm working with a system that has several external system dependencies. These external systems are only hooked into certain SDLC environments (local, dev, qa, and prod). Due to these restrictions, I have put environment checks in place on my some…
Chris Traynor
  • 460
  • 1
  • 5
  • 14
5
votes
2 answers

Angular testing mock subscribed property

I have a service with 2 properties: Service ... public usernameAnnounced; private username: Subject = new Subject(); constructor() { super(); this.usernameAnnounced = this.username.asObservable(); } On my component I want…
MarcoLe
  • 2,309
  • 6
  • 36
  • 74
5
votes
1 answer

Global function not available in Window object when using Jasmine & Headless Chrome

I'm having a hard time figuring out how I can access a function that is usually available as a method of the window object in the browser. I'm using Karma, Headless Chrome and Jasmine. Here is a simplification of my issue: I have a module called…
1
2 3
13 14