Questions tagged [jasmine]

Jasmine is a behavior-driven development (BDD) framework for testing JavaScript code. Jasmine has no external dependencies and does not require a DOM.

Jasmine is a stand-alone behavior-driven development (BDD) framework used for unit testing JavaScript code.

Jasmine tests are broken up into describe and it statements. describe is used to denote the start of a test suite and it is used to denote the start of a particular test. expect statements are then used to outline the conditions under which a test should pass.

beforeEach and afterEach are some other frequently used blocks. beforeEach is used to run some code before each test. Something like loading a module. Similarly afterEach is used to run some code after each test. Running some cleanup code for instance.

Jasmine DOM Testing

If you want to write unit tests for code that does a lot of DOM interactions using jQuery, consider using jasmine-jquery. Jasmine-jQuery offers interacting with dummy HTML through HTML fixtures.

Resources

13306 questions
5
votes
2 answers

Use Mock HTTP with Protractor and Jasmine

How can I use Mock HTTP with Jasmine and Protractor ? In my test.spec.js, I declared a mock, but this mock doesn't work. I don't have any error. My api always responds and not the mock. I never see 'mockModule!' in my console. My function is never…
Jérémie Chazelle
  • 1,721
  • 4
  • 32
  • 70
5
votes
1 answer

Jasmine - Testing links via Webdriver I/O

I have been working on a end-to-end test using Webdriver I/O from Jasmine. One specific scenario has been giving me significant challenges. I have a page with 5 links on it. The number of links actually challenges as the page is dynamic. I want to…
Some User
  • 5,257
  • 13
  • 51
  • 93
5
votes
1 answer

State of Jasmine Unit Test support of Resharper 2017: Debug mode and AMD modules supported?

I currently use Chutzpah to run and debug Jasmine Unit tests that include AMD/require.js modules. I would like switch to the test runner of Resharper 2017. However, Resharper does not seem to fully support Jasmine Unit Tests? A. Example jasmine…
Stefan
  • 10,010
  • 7
  • 61
  • 117
5
votes
1 answer

Angularjs test simple factory that return static data

How do you mock out a simple Factory in AngularJs that returns static data in a Karma unit test? I have this simple factory, that for the sake of example return static data: angular.module('conciergeApp.services') .factory('CurrentUser',…
Aaron Lelevier
  • 19,850
  • 11
  • 76
  • 111
5
votes
2 answers

How to compare width and height of element with getSize() function with Protractor test?

Good morning dear colleagues. I have a question about Selenium methods. In my case I'm testing angular application with protractor and I want to compare returns value from getSize function with set values in the my test. Here is code below - var…
Maksim
  • 155
  • 1
  • 2
  • 17
5
votes
0 answers

ReferenceError: goog is not defined when running Jasmine

I tried to execute the tests present in shaka-player source code, using the Jasmine framework via command line. But I'm getting this error message: /Documents/shaka-player/spec/mpd_spec.js:19 goog.require('shaka.dash.mpd'); ^ ReferenceError: goog is…
5
votes
1 answer

Karma/Jasmine tests fail with error: 'Uncaught Error: Module name "simple_test.js" has not been loaded yet for context: _. Use require([])'

I am using Karma and Jasmine to run tests on my project built with React. When I try to run my Karma tests I get this error in the console: Running "karma:test" (karma) task WARN `start` method is deprecated since 0.13. It will be removed in 0.14.…
CascadiaJS
  • 2,320
  • 2
  • 26
  • 46
5
votes
1 answer

How to setup Karma + Jasmine to use ES6 modules

I'm a bit stuck on this. I have a complex stack composed of middleman, karma, jasmine, babeljs to build a static website. Considering this is an experiment, I wanted to use ES6 with modules. Everything fine on middleman side, though, I'm having hard…
Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
5
votes
1 answer

How to unit test $mdSidenav service?

I am building an angular app using material design. I am using $mdSidenav service to play with a sidenav which should be able to open and close along with user desires. I have created a wrapper service around it like this: (function () { 'use…
jbernal
  • 785
  • 1
  • 14
  • 29
5
votes
3 answers

Protractor - Checking if input field has text

I'm writing a simple protractor test that's intended to check if a certain input tag contains text after a button is clicked. I've tried a few things and I'm currently trying to use protractor.ExpectedConditions to check if it contains any text.…
Sean Morris
  • 135
  • 2
  • 10
5
votes
3 answers

Karma Jasmine: Executed 0 of 0 Error

I am getting into Angular Testing with Karma and Jasmine. After doing the karma init and writing the first test for a home controller, I keep getting Executed 0 of 0 ERROR. It does not seem like it's being picked up in the files. module.exports =…
leocreatini
  • 676
  • 1
  • 9
  • 18
5
votes
1 answer

Cannot spy on angular.element

I have one Jasmine test that is continously failing due to a spyOn not executing. The following test will automatically fail: it('simple test', function() { spyOn(angular, 'element'); }); The error is: TypeError: 'undefined' is not an object…
geoff
  • 2,251
  • 1
  • 19
  • 34
5
votes
1 answer

get array of different values of the same element using protractor

i'm trying to test an application that displays graphs using rickshaw and d3. tests are implemented using protractor and jasmine. as a side note, i believe the question is not really specific to this use case and is more generic. so, the test is…
ilj
  • 859
  • 8
  • 18
5
votes
2 answers

Jasmine test state of object on Ajax method spy call

I'm unit testing an Angular controller that uses a Rails Resource factory to handle GETing and POSTing model data from and to a Rails app. POSTing is done via a method on the model, e.g. (with a model…
eirikir
  • 3,802
  • 3
  • 21
  • 39
5
votes
1 answer

Download file on Firefox with protractor

I need to download a zip file on Firefox with protractor. On clicking on download link, Windows dialog asking to Open/Save the file pops up. So How can I handle that. What args do I need to pass to driver? With chrome I can do that with download:…
1 2 3
99
100