Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
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
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
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
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 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
-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
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
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
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
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
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
0 votes
0 answers
66 views

On using jasmine reporter, I get "No spec found"

I am using jasmine-node framework for my API automation. I am able to run REST services and able to get the result using node-fetch or http. Without reporter when I run with the below command I was ...
johny's user avatar
  • 61
1 vote
1 answer
3k views

How to mock a nested method?

I'm learning more about Jasmine Unit Testing and I've ran into something that I can't figure out. I'm new to both JavaScript and Unit Testing. I've tried to look for examples about nested methods and ...
Dixon Ivey's user avatar
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....
Stefan's user avatar
  • 832
0 votes
1 answer
639 views

Testing Lodash sortBy function argument using Jasmine

I have a controller in my project that goes like this: define(function (require) { 'use strict'; function AllOrgsController($rootScope, $uibModalInstance) { var vm = this; var clonedOrgs ...
DJ22T's user avatar
  • 1,640
5 votes
1 answer
1k views

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 ...
theclarkofben's user avatar
0 votes
2 answers
68 views

How do I access information about the currently running test case from the beforeEach function?

Using Protractor 5.1.2 and Jasmine2 for describing test cases, how does one get the current testcase/spec being run in the beforeEach method? I would like to do some different setup based on which ...
S.Huston's user avatar
  • 254
0 votes
1 answer
2k views

How to mock private function of a class using jasmine test framework

I am trying to mock private function of my class. I am already testing my private method using testEmployee.__private.getStatus(). The issue I am facing is the mocking of private function getStatus. I ...
Ramesh Chandra's user avatar
0 votes
2 answers
846 views

object is not a constructor Protractor Java Script

I keep getting this message saying Newpage is not a constructor i have racked my brains out for the past 5 hours trying to resolve this issue and no progress i have looked at the following sites How ...
Jonathan's user avatar
  • 395
0 votes
2 answers
439 views

Pass a Jasmine spec on async timeout

Running Jasmine 2.8. I've got a test case in which the failure case is an event handler being triggered under a condition when it should not be. Note that the codebase that provides events here is ...
p0lar_bear's user avatar
  • 2,265
1 vote
0 answers
44 views

How to pass an Error to a function in jasmine/jest

I have the following test code: it('throws a `TypeError`', () => { expect(() => { // For context: // The second argument to this method MUST be an Error instance // The second ...
Matthew Herbst's user avatar
0 votes
2 answers
545 views

Protractor writing element inner text to a file

I am trying to grab an elements inner text and write the inner text to a file however i am having no success. the program runs and writes to csv file but just writes the what the global variable ...
Jonathan's user avatar
  • 395
0 votes
1 answer
1k views

Protractor passing variable between describe functions

I am trying to pass a variable representing an array between describe functions and I am having no luck. I have used protractor before but never passing variables between describes before. any help ...
Jonathan's user avatar
  • 395
0 votes
1 answer
2k views

Protractor element by Xpath Index

I am trying to get xpath by index and i am not making an progress. protractor says "that the element has more than one element is found for locator choosing the 1st one". however I want to make sure ...
Jonathan's user avatar
  • 395
0 votes
2 answers
90 views

Protractor hard to click popup/dropdown

Hey guys I am trying to click on an element called practitioner access on my company's web site and I have tried looking up documentation on stack over flow and have not figured out how to do this ...
Jonathan's user avatar
  • 395
0 votes
1 answer
91 views

Protractor jasmine2-html-reporterHTML verify element was clicked

My jasmine-spec-reporter verifies that an element was clicked I see the check marks in the console view however in my protractor-jasmine2-html-reporter shows that the spec was skipped when it was ...
Jonathan's user avatar
  • 395
0 votes
1 answer
31 views

Test plain javascript file returning different objects

Is it possible to test the code below with Jasmine testing tool or any other npm module like rewire or similar? const AuthValidatorDumb = require('./src/AuthValidatorDumb'); const AuthValidator = ...
ivanb's user avatar
  • 11
0 votes
1 answer
697 views

How to use jasmine to mock jquery getJSON callback

I have module that contains a load function and that load function calls jQuery's getJSON function load(key,callback){ // validate inputs $.getJSON( this.data[key],'',function(d){ switch(...
Wanderer's user avatar
  • 592
2 votes
0 answers
629 views

Overridden Jasmine spy in mock not compiling in TypeScript properly

I'm trying to override/re=assign a Jasmine spy on a mock and can't seem to get it to work. The mock looks like this: export class UserClassMock { public static instance(): any { let ...
MBielski's user avatar
  • 6,620
0 votes
0 answers
33 views

Accessing the view which has the dependecy

I have two js files, in which one view in a separate file. I am testing it using Jasmine unit testing. I have the js files included in the jasmine.html page. I am able to access everything other than ...
purnima's user avatar
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,...
Angela Roux's user avatar
0 votes
1 answer
36 views

Unit Test are not failing

I am trying to write unit test cases, for web API call. Which shows success below : Success Unit Test (jsfiddle) getProduct("jsonp","https://maps.googleapis.com/maps/api/e Error Unit Test (...
SmartestVEGA's user avatar
  • 8,849
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 ...
zelda's user avatar
  • 753
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 ...
MBielski's user avatar
  • 6,620
0 votes
1 answer
35 views

How to report posted payment is completed or skipped or failed in protractor

As my application has a payment status that changes every time based on settings, i wanted to publish in a report that for this test cases payment made is completed. Here is the code- <td class="" ...
Smitha's user avatar
  • 27
13 votes
1 answer
16k views

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('...
Dao Minh Dam's user avatar
1 vote
3 answers
672 views

What's the equivalent of jasmine.createSpy().and.callFake(fn) in sinonjs

I'm looking for the equivalent of jasmine.createSpy().and.callFake(fn) in sinonjs. For example: const mySpy = jasmine.createSpy('my spy') .and .callFake((options) => Object.assign({}, {name: 'foo'...
Ofir D's user avatar
  • 818
6 votes
1 answer
14k views

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 ...
tallpaul's user avatar
  • 1,473
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 ...
user3344978's user avatar
1 vote
1 answer
171 views

protractor is closing Chrome browser as soon as browser opened without entering in url

It was working fine and all of sudden it's behaving weird. Opening Chrome with in address bar as "not secure : data:" and not entering in URL. I have tried updating webdriver-manager update too but ...
lakeshoredrive's user avatar
1 vote
1 answer
189 views

Why can't jasmine find my source code with rake jamine:ci?

I can rake jasmine to run the server and then visit http://localhost:8888/SpecRunner.html and I get but when I do rake jasmine:ci 0 specs are found. I moved PlayerSpec.js to spec/javascripts/ and ...
Michael Durrant's user avatar
1 vote
1 answer
152 views

jasmine mockDate always one month off

I'm trying to use jasmine's mockDate() to write a time-relative unit test: it("cookie_expiration() is 30 days out", function () { var baseTime = new Date(2016, 10, 1, 0, 0, 0, 0); jasmine....
emersonthis's user avatar
  • 33.3k
3 votes
1 answer
821 views

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")); ...
Ajay Patil's user avatar
1 vote
1 answer
733 views

How to use Jasmine to Spy on Modules being loaded by requireJS?

So I'm using Typescript/RequireJs/Jasmine, and can't get my spy to work for modules loaded in another module. Here is my Spec: import { CrmWebApiLib } from "../../../webresources/allgnt_/scripts/...
Daryl's user avatar
  • 18.9k
3 votes
1 answer
3k views

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. ...
3-MeO-PCE's user avatar
5 votes
2 answers
4k views

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 ...
ps0604's user avatar
  • 1,031