Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tags Protractor + Jasmine to run set of suites

I'm trying to figure out a way to use in the same way, or better said, similar way, the tagging options that cucumberJS has with protractor, but with Jasmine, is there a way to tag the different scenarios, like: @smoke, @regression, etc.. and then tell on console to run with those?

I'm declining to use Cucumber, since it's support it's seems to be getting flaky!

Any help will be much appreciated!

like image 598
Bruno Soko Avatar asked Nov 30 '15 17:11

Bruno Soko


People also ask

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.

Why Jasmine is used in protractor?

Jasmine is a test framework, which provides BDD (Behavior Driven Development) functionalities for your automation framework. It is an independent framework i.e there is no dependency with other framework and doesn't require DOM. A describe-block, it-block, and an expectation with matcher makes one complete test script.

What is Protractor config?

The configuration file tells Protractor how to set up the Selenium Server, which tests to run, how to set up the browsers, and which test framework to use. The configuration file can also include one or more global settings.


2 Answers

With jasmine2 you can filter tests using a regular expression. Maybe you can add something like @smoke, @regressions to your tests and then only run those ones by passing the grep flag:

it('should do stuff @smoke', function() {
  ...
});

Then run protractor passing the grep flag:

protractor conf.js --grep='@smoke'

like image 60
Andres D Avatar answered Nov 15 '22 16:11

Andres D


Alternative to grep would to be to use suites:

suites: {
    smoke: [ 
        "spec1.js",
        "spec2.js",
        "spec3.js"
    ],

    regression: [
        "spec4.js",
        "spec5.js",
    ],
}

Then, run protractor specifying the suite argument:

protractor conf.js --suite smoke
protractor conf.js --suite regression
protractor conf.js --suite smoke,regression
like image 20
alecxe Avatar answered Nov 15 '22 16:11

alecxe