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.
Asked
Active
Viewed 149 times
1
-
Correct me if I'm wrong: basically you want to group `it()`s instead of test files? – alecxe Sep 22 '15 at 15:27
-
Yes alecxe, is there way to pick them up from different spec files and create a new spec file or some way? – Jyothish Sep 22 '15 at 15:35
1 Answers
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 () {
});
});
-
1Jasmine2 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
-
-
-
-
@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