From 507db4773c9cca24050c39a07c6ae37e2e7e3bd6 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Thu, 21 Apr 2016 12:10:42 +0200 Subject: [PATCH] Test: Update test README --- test/README.md | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/test/README.md b/test/README.md index 65bdc61b0286f..d8f314f2d365c 100644 --- a/test/README.md +++ b/test/README.md @@ -1,44 +1,15 @@ ## Single test runner -Single test runner loads only test files that are listed in `tests.json` file in top level directory. Configuration reflects folders structure. +### How to add a new test file -### Extending tests.json +Single test runner supports automatic test discovery. You only need to put your test file into `test` subfolder next to file under test. +Runner uses this `glob` pattern `@(client|server|test)/**/test/*.@(js|jsx)` to find test files. -Config file location: `client/tests.json` +We should use the same name for test file like we named test we want to cover with tests. -Example folder: `client/state/plugins/wporg/test/` - -Test files we want to add to the runner: -* `actions` -* `selectors` -* `reducer.js` - -It translates into the following code in the config file: -```js -{ - "state": { - "plugins": { - "wporg": { - "test": [ "actions", "selectors", "reducer" ] - } - } -} -``` - -Test output for added files: -``` -... -state - plugins - wporg - reducer (taken from describe inside the file) - √ Test name - test-actions - √ Test name - test-selectors - √ Test name -... -``` +If we ever need to add non-test files to `test` folder we should put them on a deeper level. Common choices are: +* `test/mocks/name.js` for test mocks +* `test/fixtures/name.js` for test data ### How to run single test runner