-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow worker CLI flags to be specified
This removes AVA's internal flags, set by fork.js and consumed by test-worker.js. Fixes #1393. AVA now forwards arguments, provided after an `--` argument terminator, to the worker process. Arguments are available from `process.argv[2]` onwards.
- Loading branch information
1 parent
9482a9e
commit ac300c1
Showing
20 changed files
with
53 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Passing arguments to your test files | ||
|
||
You can pass command line arguments to your test files. Use the `--` argument terminator to separate AVA's arguments from your own: | ||
|
||
```js | ||
// test.js | ||
import test from 'ava'; | ||
|
||
test('argv', t => { | ||
t.deepEqual(process.argv.slice(2), ['--hello', 'world']); | ||
}); | ||
``` | ||
|
||
```console | ||
$ npx ava -- --hello world | ||
``` | ||
|
||
You need two `--` argument terminators if you're invoking AVA through an `npm test` script: | ||
|
||
```json | ||
{ | ||
"scripts": { | ||
"test": "ava" | ||
} | ||
} | ||
``` | ||
|
||
```console | ||
$ npm test -- -- --hello world | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import test from '../../'; | ||
|
||
test('argv', t => { | ||
t.deepEqual(process.argv, [process.execPath, require.resolve('../../lib/test-worker.js'), '--hello', 'world']); | ||
}); |