Skip to content

Commit ceaa834

Browse files
authored
Merge pull request #18372 from mozilla/better-auth-testing-readme
polish(auth): Better readme for testing commands
2 parents 131d156 + e351f00 commit ceaa834

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

packages/fxa-auth-server/README.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,42 @@ Linting will also be run for staged files automatically via Husky when you attem
3232

3333
## Testing
3434

35-
Run tests with:
35+
Before running tests make sure the correct services are running. If auth server is running in pm2 weird behavior can ensue, so
36+
prior to running tests we recommend creating a clean slate by running `yarn stop`.
3637

37-
npm test
38+
Now we can start testing. To run unit tests:
3839

39-
Run specific tests with the following commands:
40+
- `nx test-unit fxa-auth-server`
41+
_Note this matches how auth server unit tests jobs in CI._
4042

41-
```bash
42-
# Test only test/local/account_routes.js
43-
# Note: This command does not work for remote tests.
44-
npm test -- test/local/account_routes.js
43+
To run integration tests, we have to make sure databases and auxillary services required for integration testing are spun up.
44+
So run:
4545

46-
# Grep for "SQSReceiver"
47-
NODE_ENV=dev npx mocha -r esbuild-register test/*/** -g "SQSReceiver"
48-
```
46+
- `yarn start infrastructure`
47+
- `nx start fxa-customs-server`
4948

50-
To select a specific glob of tests to run:
49+
Now unit tests can be executed:
5150

52-
```
53-
npm test -- test/local/account_routes.js test/local/password_*
54-
```
51+
- `nx test-integration fxa-auth-server`
52+
_Note this matches how auth server unit tests jobs in CI._
5553

56-
To run a certain suite of tests (e.g. all remote tests):
54+
For general development based testing, specific tests can be targeted using the test script or use mocha directly:
5755

58-
```
59-
npm test -- test/remote
60-
```
56+
_From packages/fxa-auth-server:_
57+
58+
- `yarn test -- test/local/account_routes.js`
59+
- `yarn test -- test/local/account* test/local/password_*`
60+
- `yarn test -- test/remote`
61+
- `NODE_ENV=dev npx mocha -r esbuild-register test/*/** -g "SQSReceiver"`
62+
63+
Notes / Tips:
6164

62-
- Note: stop the auth-server before running tests. Otherwise, they will fail with obscure errors.
63-
- You can use `LOG_LEVEL`, such as `LOG_LEVEL=debug` to specify the test logging level.
65+
- For quick enviroment config, consider running tests with a .env file and the dotenv command. For example: `dotenv -- yarn workspace fxa-auth-server:test-integration remote`
66+
- you can use `LOG_LEVEL`, such as `LOG_LEVEL=debug` to specify the test logging level.
67+
- recovery-phone tests require twilio testing credentials!
68+
- recovery-phone-customs tests require that customs server is running. So run `nx start fxa-customs-server` prior to executing tests.
6469

70+
_Other Stuff_
6571
This package uses [Mocha](https://mochajs.org/) to test its code. By default `npm test` will run a series of NPM test scripts and then lint the code:
6672

6773
Refer to Mocha's [CLI documentation](https://mochajs.org/#command-line-usage) for more advanced test configuration.

0 commit comments

Comments
 (0)