Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

protractor how do you run a single test case?

Tags:

protractor

I'm using protractor 1.8.0 and jasmine 2.1.3 but I can't run a single test when I use ddescribe and then iit. I get:

Message: ReferenceError: iit is not defined

I have a lot of test cases and want to just run 1 for debugging purposes. Is there a way to do this?

Do I need to $npm install jasmine-focused or is it already part of jasmine 2.1.3?

@Aaron I went ahead and uninstalled and reinstall. Ran the test and got the same error. Here is the output after install.

/usr/local/bin/protractor -> /usr/local/lib/node_modules/protractor/bin/protractor
/usr/local/bin/webdriver-manager -> /usr/local/lib/node_modules/protractor/bin/webdriver-manager
[email protected] /usr/local/lib/node_modules/protractor
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
like image 962
awaken Avatar asked Mar 05 '15 20:03

awaken


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 you run the same test multiple times in protractor?

When you want to run protractor scripts by opening a browser instance for each test, you should add two capabilities shardTestFiles and maxInstances in the Capabilities block of the conf. js file. This will help to execute your scripts on same browser with multiple instances.


1 Answers

The syntax for that as of 2.1 is fdescribe and fit. Source

describe('a test', function() {
    it('spec 1', function() {
        console.log('1');
    });

    it('spec 2', function() {
        console.log('2');
    });

    it('spec 3', function() {
        console.log('3');
    });
});

This will print:

1
.2
.3
.

Meanwhile:

fdescribe('a test', function() {
    it('spec 1', function() {
        console.log('1');
    });

    fit('spec 2', function() {
        console.log('2');
    });

    it('spec 3', function() {
       console.log('3');
    });
});

Will print:

2
.
like image 72
Aaron Avatar answered Oct 12 '22 19:10

Aaron