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
5
votes
1 answer

How to spyOn a global function and return a value in Jasmine

How can I spy on MyFunction and return 2 in Jasmine 2.0? I have the following code that errors on the first line inside shouldPass with: Error: function MyFunction(){ return 1; }() method does not exist It appears to be using the entire function…
tallpaul
  • 1,220
  • 2
  • 13
  • 35
5
votes
1 answer

Protractor 2.5.1 ReferenceError: testFn is not defined

I recently upgraded to protractor 2.5.1 and all of my tests are now failing. I suspect it is something to do with Jasmine but I'm not sure how to fix. Any help would be appreciated, thank you in advance. Here is the error I receive: Should login…
formarfr
  • 53
  • 4
4
votes
1 answer

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 place. expect(1).toEqual(1) // Would complain about…
Trevor Murphy
  • 131
  • 1
  • 6
4
votes
1 answer

Testing async pipeable operators in RxJS

Sometimes we have functions, which modifies original source using async operators like delay. Lets assume we have something really simple: // Old syntax function modify(source) { return source.delay(1000); } I am using marbles to test RxJs, so…
ilyabasiuk
  • 4,270
  • 4
  • 22
  • 35
4
votes
1 answer

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 it while testing. In the Ionic demos it appears in…
MBielski
  • 6,628
  • 3
  • 32
  • 43
4
votes
2 answers

Jasmine toEqual fails but printing the two objects are identical

In this Jasmine test I compare two objects that are almost identical, the only difference is that the second object has an additional undefined member. describe('Testing', function () { it('should compare two objects', function () { var…
ps0604
  • 1,227
  • 23
  • 133
  • 330
4
votes
0 answers

Protractor-fail-fast npm fails spec and doesn't run the rest specs (tests) in config file (using Protractor with Jasmine)

I have an issue while using npm protractor-fail-fast. ( https://www.npmjs.com/package/protractor-fail-fast ) If one spec file is failed, the rest specs will be NOT executed (NOT GOOD). I'm searching an approach how to fail describe with many 'it'…
3
votes
1 answer

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 couple days back, but seeing this issue now using…
Adam reed
  • 31
  • 1
  • 2
3
votes
0 answers

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 as a whole, a few of the tests fail because of the…
ShellZero
  • 4,415
  • 12
  • 38
  • 56
3
votes
1 answer

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.getContext(); this.language = context.language; …
Stefan
  • 832
  • 8
  • 10
3
votes
2 answers

How to compare json object in Jasmine

I want to compare JSON object's keys in the Jasmine. For ex: I have JSON object with two keys, I want to check if JSON contains both the via Jasmine. { "key1": "value1", "key2": "Value2" } If i have this JSON i want to check if JSON contains both…
hardiksa
  • 1,477
  • 1
  • 14
  • 19
3
votes
1 answer

How to click all the links one by one using protractor?

I have stored all the link elements in var as below- it("should click all the links one by one", function() { browser.get("https://angularjs.org"); var allLinks=element.all(by.tagName("a")); var number=allLinks.count(); …
Ajay Patil
  • 159
  • 1
  • 7
3
votes
1 answer

Jest async test times out if "expect" called within async function. Works sometimes. "Async callback was not invoked within timeout specified"

I am using Jest with JS and trying to write a test around the X-ray JS library, a web scraping toolkit. The following is the test. This is using Jest 18.x and the latest x-ray js as of 02/20/2017. const htmlResponse =…
3-MeO-PCE
  • 31
  • 1
  • 2
3
votes
1 answer

React Jest Testing onSubmit

I am new to react and jest. I have been looking everywhere for testing but I cannot find anything that is helpful. This is partially because I am so new to it, I havent a clue where to start. So bear with me, please. I have an add to cart file…
Robby
  • 183
  • 2
  • 2
  • 13
2
votes
1 answer

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 to > 4 and this resulted in a many errors. See…
Nils Walker
  • 159
  • 1
  • 1
  • 9
1
2
3
13 14