Run individual Detox test

Edit: Turns out you don't need the -f flag at all.

You can just do detox test /path/to/yourTest.spec.js and it works for single files (tested on v14.4.1).

Source

I ended up using the -f parameter for testing a specific test.

detox test -f /path/to/yourTest.spec.js

Came across it from the repo. Looks like it may have been updated.


Consider the following code for running particular suite

describe.only('App screen', () => {
    beforeEach(async () => {
        await device.reloadReactNative();
    });

In the above code "Only" will run the whole test suite.

Consider the following code for running particular test case

it.only('should write into TextInputs', async () => {
            await element(by.id("input")).typeText("Detox Automation POC-Test for enter text and delete text");
            await element(by.id("input")).clearText();
            await element(by.id("input")).replaceText("Bye");

In the above code "Only" will run the particular test case.


Preface:
Detox is test runner agnostic, you can actually use which ever test runner you want. The only thing we did is try to make dev life easier by creating detox-cli, which currently only works with mocha and jest, but you can easily extend it to any other runner. While I agree the implementation of detox-cli is not perfect (params are not being passthrough from to test runner, and generally it needs a bit of work), its pretty easy to add whatever you want in detox-test.js.

Actual answer:
In the meantime, the fastest way to to run individual test is by using only to to mark the suites/tests you want to run: describe.only and it.only.


workaround can be helpfull. Did it also for ssh-channel to remote host with detox through ssh:

  1. create another folder for tests (not e2e, f.E. "temp-tests") on the same folder-structure level.
  2. copy all your tests to temp-tests
  3. write small script and start it from "e2e" folder. It will :

    delete all tests in e2e, then will take only one test from "temp-tests" and put it to "e2e" folder and start it.

4 (optional) also one can write saving of mocha-report into another file for each test for reporting issues.

script: //////////////////////////////////////////// rm *.spec.js cd ../run-tests cp unique-testname ../e2e/ detox test --configuration yourapp.initial

Tags:

Detox