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

Run individual Detox test #536

Closed
CodingItWrong opened this issue Jan 23, 2018 · 18 comments
Closed

Run individual Detox test #536

CodingItWrong opened this issue Jan 23, 2018 · 18 comments

Comments

@CodingItWrong
Copy link
Contributor

Running detox test runs all tests in the suite. Is there a way to run a subset of the tests? A single test file, or a single test case.

I've configured Detox to use Mocha as the test runner, as per the docs. I know that Mocha has a -g option to specify a pattern for the tests to run. But options passed to the detox command don't seem to be passed along to mocha (which makes sense):

# detox test -g mytestcase

error: unknown option `-g'

I can use Mocha's .only() function to designate one it() or describe() to run—but that involves changes in the source code. It would be great if I could have the option to use a command-line argument to specify which test to run instead. That would certainly be test-runner-specific, of course—so I think providing a way to pass arbitrary command-line arguments from detox test along to the test could be good.

I'm attempting to use Detox for TDD, and the quicker the feedback I can get, the better. As my test suite grows, it would become less and less motivating to run tests as I develop if the time to run gets longer and longer.

@rotemmiz
Copy link
Member

It may be a good idea to passthrough command line arguments to test runners.
As always, this is a really good PR candidate :)

@CodingItWrong
Copy link
Contributor Author

OK great, I will investigate! (I meant to say that.) This feels like it'd be an easier PR to start with than my #518 proposa.

@kdenz
Copy link

kdenz commented Jan 24, 2018

This is needed by our team as well!

@heuism
Copy link

heuism commented Feb 1, 2018

you can use cucumber like i did for as the test runner. with Cucumber, there is a tag for the scenario and therefore can run your specific test case with the tag.

@rwgatorfan
Copy link

My team could also use this

@jeremyeaton89
Copy link
Contributor

just curious to understand pros and cons of passing this particular flag to the test runners vs just overriding testFolder, like this, if anyone has insight

@kylethebaker
Copy link

This is something that I think is really important to have given how long some of the tests can take to run.

@sinewave440hz
Copy link

arbitrary command-line arguments from detox test, yes please! :) I'm using jest and have much more success with my tests when running detox test than using the jest runner directly. This would be a very useful enhancement.

@juddey
Copy link

juddey commented Feb 20, 2018

This'd be a real time-saver :)

@kdenz
Copy link

kdenz commented Feb 26, 2018

Would be great if this is supported soon :)

@CodingItWrong
Copy link
Contributor Author

Update to anyone who finds this issue, I've ended up less available than I thought. Anyone else is welcome to pick up this issue.

In the meantime in Mocha using it.only() and describe.only() is probably your best bet. https://mochajs.org/#exclusive-tests

@nezaidu
Copy link

nezaidu commented Mar 29, 2018

+1

@wildseansy
Copy link

wildseansy commented May 9, 2018

another temporary workaround is you can edit the e2e/mocha.opts, and add a --grep argument or --file to only run a test file matching a certain string

@lukasgjetting
Copy link
Contributor

Has work been started on this? If not, I will start working on it.

@CodingItWrong
Copy link
Contributor Author

I haven't started work on this or heard of anyone who has. FYI though this PR implements something related that is Jest-specific. It's probably worth looking into how it's implemented to see if this issue is still needed: #1083

@lukasgjetting
Copy link
Contributor

lukasgjetting commented Dec 21, 2018

Seems like a solution has already been implemented in #1025.

Though it hasn't been released yet. Does anyone know the release schedule?

@jeremyeaton89
Copy link
Contributor

There's currently a way to run a single test.. e.g. detox test -c ios -f /path/to/file

@CodingItWrong
Copy link
Contributor Author

@jeremyeaton89 Nice, thanks for adding us and for letting us know! I'm closing this issue as the -f option satisfies just what I was looking for.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests