Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to run a single test from the command line? #164

Closed
gsastry opened this issue Oct 11, 2013 · 18 comments
Closed

Is there a way to run a single test from the command line? #164

gsastry opened this issue Oct 11, 2013 · 18 comments

Comments

@gsastry
Copy link

gsastry commented Oct 11, 2013

I'd like to pass in a single test name to run from the command line. Is this possible? (new to jasmine/protractor, any help would be appreciated)

@juliemr
Copy link
Member

juliemr commented Oct 11, 2013

You can run a single file with --specs mydir/mytestfile.js

Running a single test is currently unsupported - looking forward to it.only support in Jasmine 2.0.

@juliemr juliemr closed this as completed Oct 11, 2013
@immer
Copy link

immer commented Dec 18, 2013

For posterity, Jasmine 2 has been released: https://github.com/pivotal/jasmine/releases/tag/v2.0.0

@christianrondeau
Copy link

So is there a way to run a single test from the protractor command line, now that Jasmine 2 is out?

@juliemr
Copy link
Member

juliemr commented Feb 28, 2014

See notes on difficulties updating to Jasmine 2 here: #362

And for the record, it doesn't support it.only :(

@F1LT3R
Copy link

F1LT3R commented Aug 10, 2015

So... now that it is supported in Jasmine 2.0: how is this done with Protractor?

@mmigdol
Copy link

mmigdol commented Aug 14, 2015

For anyone looking to do this in Jasmine 2.0+, use ddescribe or iit to isolate a single describe() or it() function. I couldn't find this documented anywhere, but discovered it via this StackOverflow question

@Bretto
Copy link

Bretto commented Aug 26, 2015

For Karma now you have to use fdescribe or fit ('f' is for focus). How ever in the protractor context nothing is working...

@rohitkadam19
Copy link

Without fit and xit how can we run single test in protractor?

@cancerberoSgx
Copy link

Don't know from the command line, but you can do it using the API like this

var jasmine = new Jasmine();
jasmine.specFiles = ['/home/sg/myproject/foo/bar/someSpec.js'];
jasmine.execute();

@sumittech17
Copy link

Hi All, @juliemr

Is it possible to run a single test or group of tests (not complete file) in protactor from command line ?

I tried using --grep option , but it is not working .

Note : Using framework: 'jasmine2'

@Xotabu4
Copy link

Xotabu4 commented Apr 5, 2016

@sumittech17
Hi, i don't know if that would help - i mark tests that i want to run in a file with - fdescribe or fit - this skips all tests except marked, then you could run your protractor with --specs mydir/mytestfile.js
It works for me, but makes you keep eye on to not commit fit or fdescribe to repo.

@sumittech17
Copy link

@Xotabu4
this is working for me now .
protractor --specs='tests/e2e/login.js' --grep="SingleLoginTest"

However I am not able to add GREP option in gruntfile now .

@jasminejeane
Copy link

@Xotabu4 Thank you so much ... that worked for me !!!!

@sakovias
Copy link

sakovias commented Sep 29, 2016

In my test suite I have nested describes some of which have afterAll or beforeAll hooks. I'm noticing that in --grep mode I have beforeAll and afterAll hooks from unrelated tests being executed. This is not the case with mocha.

Basically before/after hooks run event though the test itself is skipped. Anyone else finding this inconvenient?

@andyman09
Copy link

Hi @sakovias, I am having the same issue on with using --grep. Did you happen to find any solution to skip beforeAll for spec that does not match the grep value?

@vickyru
Copy link

vickyru commented Dec 4, 2019

This is what working for me, if i want to run a particular 'it' block from a particular suit

protractor protractor.conf.js --suite test-suite-name --grep="it-block-name"

@juanbrein
Copy link

You can do all that, but I found way more convenient to have a wrapper script that basically inject the files I want to test on the protractor.config.ts. Then I write one test per file and use a common sense naming convention like:

user/create-article.e2e.ts
user/update-article.e2e.ts
user/delete-article.e2e.ts

So now I can run things like

./run-e2e.sh user/create

Sometimes is easier to build things yourself ...

@vickyru
Copy link

vickyru commented Dec 19, 2019

You can do all that, but I found way more convenient to have a wrapper script that basically inject the files I want to test on the protractor.config.ts. Then I write one test per file and use a common sense naming convention like:

user/create-article.e2e.ts
user/update-article.e2e.ts
user/delete-article.e2e.ts

So now I can run things like

./run-e2e.sh user/create

Sometimes is easier to build things yourself ...

For sure it will work I didn't think it is good way to achieve it as if one have to change any config.js property he/she have to in all three places. More configuration file more will be the fragility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests