1

Is there a way to cherry pick the tests and create suits in protractor/jasmine e2e test. I know protractor accepts with wildcard specs (*.spec") in the suites, but I am looking for select few tests in spec files and create a suit to run on protractor. Any help on this is greatly appreciated.

Jyothish
  • 541
  • 2
  • 5
  • 25

1 Answers1

3

suites can only group test files. Though, I would still think about regrouping the specs inside tests, or splitting them into multiple files so that suites can be used here - it is a great way to organize your tests and group them logically.


If you want to run specific it() blocks/specs from different files as a part of a group - tag them:

describe("test1", function () {
    it("should test something (#mytag)", function () {

    });
});

describe("test2", function () {
    it("should test something else (#mytag)", function () {

    });
});

And run with --grep:

protractor conf.js --grep "#mytag"

See also:


Alternatively, use focused specs (fdescribe/fit, or ddescribe/iit):

describe("test1", function () {
    fit("should test something", function () {

    });
});

describe("test2", function () {
    fit("should test something else", function () {

    });
});
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • 1
    Jasmine2 supports ddescribe() and iit() as well, but I believe they both do the same thing. – MBielski Sep 22 '15 at 15:47
  • I think --grep is the only way out, basically to categorize test as smokeSpec.js or FullSpec.js – Jyothish Sep 22 '15 at 16:11
  • @Jyothish got it, you cannot use suites currently since you have basically multiple keys to group - functional, smoke, performance etc. Yeah, focused tests is a temporary thing. `grep` may be a good option for you. You can also make a separate group of test files that would "import" (using, for instance,[`require`](http://stackoverflow.com/questions/16423156/getting-requirejs-to-work-with-jasmine)) other tests..this way you may have, say, a directory of smoke tests that would import some of the functional tests..just thoughts. – alecxe Sep 22 '15 at 16:14
  • @Jyothish this is also related: http://stackoverflow.com/questions/5061512/whats-a-good-way-to-reuse-test-code-using-jasmine. – alecxe Sep 22 '15 at 16:16
  • @alecxe, I don't see --grep as argument to protractor command – Jyothish Sep 23 '15 at 13:58
  • @Jyothish okay, what version are you using? – alecxe Sep 23 '15 at 14:01
  • @alecxe version 2.2.0 – Jyothish Sep 23 '15 at 14:12
  • @Jyothish yeah, the `--help` does not show it, but it's there, please see: https://github.com/angular/protractor/blob/master/lib/cli.js#L64. – alecxe Sep 23 '15 at 14:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/90447/discussion-between-jyothish-and-alecxe). – Jyothish Sep 23 '15 at 14:28