Run Specific Test


#1

Hi there.
How would one run a specific test?
If I have for example test/functional/auth.spec.js how can I run just that specific test?


#2
$> node ace test -h

Usage:
  test [group] [options]

Arguments:
  group                 Define the test groups to be executed. Multiple groups are seperated by comma

Options:
  -b, --bail            Stop running tests on first failure
  -t, --timeout <value> Define a global timeout for all the tests
  -f, --files <value>   Pick only specific files. File names are seperated by comma
  -g, --grep <value>    Grep on tests title to run only selected tests
  --glob <value>        Define a custom glob to pick test files

About:
  Run application tests

So that would be the --files option.


#3

Excellent! It works, thanks


#4

Test runners such as mocha allow you to add a .only to a test or suite of tests, is this possible using the test runner that ships with adonis?

Running a single spec with mocha:

describe(function () {
  // these tests will be skipped
});

describe.only(function () {
  // these tests will run
});

Running a single test with mocha:

it.only(function () {
  // this test will run
});

it(function () {
  // this test will be skipped
});

#5

Not possible and I’ve opened an issue for that, I think already.

But you can use the command line --grep option to limit to a specific test by name. Not the optimal solution, of course, but it could work in some cases.

I’d also love to have .only option, especially when developing tests or running them thru a debugger.


#6

@moltar Do you possibly have a link you can share for the referenced issue?


#7