When running jasmine it only presents dot(.) for successful tests, and only verbose if the test fails. My running command is: jasmine-node test.spec.js The result: How to make jasmine display this test result like jasmine should show this text? Answer Use the –verbose flag: Note: jasmine-node doesn̵…
Tag: jasmine
Protractor – ScriptTimeoutError: asynchronous script timeout: result was not received in 20 seconds
I’m new to Protractor and I am trying to run my script. But whenever I run it the browser opens up and proceeds to the website and then waits for 20 sec and I get Error: ScriptTimeoutError: asynchronous script timeout: result was not received in 20 seconds. The element is clearly there and can be clicke…
Getting `TypeError: jest.fn is not a function`
I’m trying to create the following unit test using Jest. But I’m getting the following error after running npm test. TypeError: jest.fn is not a function This is some section of my package.json: What could be the reason I’m getting that error? Answer The jest object is automatically in scope…
What is the alternative for “toNotEqual” in Jasmine?
I am trying to write Unit Test in Jasmine and in my code, I am comparing two objects for inequality. I am using following code to do it: But getting following error: TypeError: expect(…).toNotEqual is not a function Can anyone please suggest how to resolve this? Answer It could have been more useful if …
How to check multiple arguments on multiple calls for jest spies?
I have the following function in a React component: This is my test that at least gets the spy to be called: However, the assertion is not working: What is the right way to use toHaveBeenCalledWith? Answer I was able mock multiple calls and check the arguments this way: where mockFn is your mocked function na…
jasmine partial string matching
I love the partial object matching that jasmine.objectContaining provides: Is there a jasmine equivalent for strings? something along the lines of: I’d like to look at a specific argument without resorting to assertions off mySpy.calls: Answer There isn’t anything of this sort in Jasmine. But you …
Meteor Velocity with Jasmine not returning expecting result?
I’m trying to test the following which works manually: Return a list of users as <div>’s Click a button to reduce that count of <div>’s by one. This does not seem to be working: I’m confused on why it does this. I clearly get the expected result when testing manually. I thi…
Disable Jasmine’s fdescribe() and fit() based on environment
fdescribe() and fit() are great for reducing noise when you’re working on a subset of tests. I sometimes forget to change them back to describe()/it() before merging my branch into master. (It’s okay to have them in separate branch while working on code – i.e. a pre-commit check wouldn’…
Protractor, with isDisplayed() I get NoSuchElementError: No element found using locator
In protractor 2.0, I am checking in a expect() if one element is displayed. I expect a false, but the weird thing is that I get following error: NoSuchElementError: No element found using locator: By.id(“userForm”) My code is: I understand that I get that error because element is not longer on the…
Global variables in Karma test runner
I have a global variable defined in my main template, which I use to store information bits from the back end, such as the environment context path. I can’t move that variable inside a service. How can I expose that variable to Karma when I run the unit tests? Answer You either declare that global varia…