Skip to content

Commit

Permalink
tests: Consolidate and simplify structure
Browse files Browse the repository at this point in the history
If we had extensive tests or groups of tests we only wanted to run some
of the time, it might make sense to split up tests into broad buckets
like "e2e", "smoke", and "unit", but we have only three test files and
~always run them all anyway.  Individual files or sets of files can
still be run directly with jest.

Removes NODE_ENV=test declaration, as Jest already sets it, and removes
ENV=dev because it doesn't appear to be needed.

Removes "npm run test:unit" command which should have been removed when
the sole file in test/unit/ was removed by "Remove the now-unused
isRequestBackedByAuspiceDataset() function" (f0c6dcd).
  • Loading branch information
tsibley committed Nov 23, 2021
1 parent 3cf7065 commit 8d708e4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 17 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ scratch
/data

# test logs
/test/end-to-end/server.log
/test/smoke-test/server.log
/test/server.log
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,21 @@ See the [infrastructure documentation](./docs/infrastructure.md) for details.

---
## Testing
Nextstrain.org currently implements limited smoke-testing to test requests originiating from the Auspice client to the nextstrain.org server (i.e. API GET requests starting with `/charon/`).
These are defined [in this JSON file](./test/smoke-test/auspice_client_requests.json) and can be run via
Nextstrain.org currently uses limited automated testing defined in `test/*.test.js` files.
Run the tests with:

```
npm run test:ci
```
npm run test:ci

This will run a local server for the duration of the tests.
Alternatively, you can run your own server in the background and run:

npm run test

instead.

To run a single test or small number of test files, run a local server and invoke Jest directly, for example:

Which will run a local server for the duration of the tests.
Alternatively, you can run your own server in the background and run `npm run smoke-test`.
npx jest --run-tests-by-path test/routing.test.js

---

Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ if (!source.visibleToUser(req.user)) {

## Tests

There are a number of smoke-tests for these API calls.
See `tests/smoke-test/` for details and run via `npm run smoke-test:ci`
There are a number of tests for these API calls.
See `test/auspice_client_requests.test.js` for details and run via `npm run test:ci`
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
"set-up": "npm run build",
"server": "node server.js",
"start": "npm run server",
"smoke-test": "NODE_ENV=test ENV=dev jest --roots ./test/smoke-test/",
"e2e-test": "NODE_ENV=test ENV=dev jest --roots ./test/end-to-end/",
"e2e-test:ci": "start-server-and-test 'node server.js --verbose >./test/end-to-end/server.log 2>&1' http://localhost:5000 e2e-test",
"smoke-test:ci": "start-server-and-test 'node server.js --verbose >./test/smoke-test/server.log 2>&1' http://localhost:5000 smoke-test",
"test:ci": "npm run smoke-test:ci && npm run e2e-test:ci;",
"test:unit": "jest ./test/unit*",
"test": "jest --roots ./test/",
"test:ci": "start-server-and-test 'node server.js --verbose >./test/server.log 2>&1' http://localhost:5000 test",
"dev": "./develop.sh"
},
"dependencies": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8d708e4

Please sign in to comment.