Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a single specific test case when using protractor

I am using protractor for angular js testing in my app and have around 19 test cases at the moment, of which one of them is failing

describe('Login page', function() {  beforeEach(function() {   browser.ignoreSynchronization = true;   ptor = protractor.getInstance(); });  it('should contain navigation items', function(){   //test case code here });  it('should login the user successfully', function(){    //test case code here }) }); 

Currently, I run all the test cases. But, how can I run just one test case to debug an issue for example one which is described as "Login page should login the user successfully"?

like image 872
Shyam Visamsetty Avatar asked Jul 02 '14 16:07

Shyam Visamsetty


People also ask

How do you run a single test case on a protractor?

describe('Login page', function() { beforeEach(function() { browser. ignoreSynchronization = true; ptor = protractor. getInstance(); }); it('should contain navigation items', function(){ //test case code here }); it('should login the user successfully', function(){ //test case code here }) });

How do I run a specific block in protractor?

If want to execute a particular test suite or test case then we can be preceding with 'f' focus i.e., 'fdescribe' will execute that suite and 'fit' will execute that particular 'it' block.

How do you run test cases sequentially in a protractor?

You could specify a glob that will load files in alphabetical order, or pass a list that forces sequential execution in the order you specify. specs: [ 'test/stories/login. js', 'test/stories/home/overview. js', 'test/stories/home/purchase/widget.

How do you run a single test case in Jasmine?

You can use fit() or fdescribe() instead of it() and describe() to achieve what is known as focussed test cases. describe("test spec", function() { it("test case 1", function() { }); fit("test case 2", function() { }); }); In the above example, only test case 2 would get executed.


1 Answers

Jasmine added fit and fdescribe in 2.1 for running single tests or describe blocks.

http://pivotallabs.com/new-key-features-jasmine-2-1/

This feature almost made it in the 2.0 release. Now enough of this functionality is present to support fit and fdescribe for focused spec and suite running.

from 2.1 git lib/jasmine-core/jasmine.js

var jasmineInterface = { describe: function(description, specDefinitions) {   return env.describe(description, specDefinitions); },  xdescribe: function(description, specDefinitions) {   return env.xdescribe(description, specDefinitions); },  fdescribe: function(description, specDefinitions) {   return env.fdescribe(description, specDefinitions); },  it: function() {   return env.it.apply(env, arguments); },  xit: function() {   return env.xit.apply(env, arguments); },  fit: function() {   return env.fit.apply(env, arguments); }, 
like image 77
Justin Avatar answered Sep 19 '22 15:09

Justin