TESTING.md
# Testing the Bugsnag JS notifier
## Initial setup
Clone and navigate to this repo:
```sh
git clone git@github.com:bugsnag/bugsnag-js.git --recursive
cd bugsnag-js
```
Install top level dependencies:
```js
npm i
```
Bootstrap all of the individual packages:
```sh
npm run bootstrap
```
Build each of the standalone packages:
```sh
npm run build
```
## Unit tests
Runs the unit tests for each package.
```sh
npm run test:unit
```
## Type tests
This tests the validity of .d.ts files by attempting to compile a TypeScript program that uses Bugsnag.
```sh
npm run test:types
```
## Linting
Lints the entire repo with ESLint. On JavaScript files this uses the [standard](https://github.com/standard/eslint-config-standard) ruleset and on TypeScript files this uses the [@typescript/eslint](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) recommended set of rules.
```sh
npm run test:lint
```
## End to end
These tests are implemented with our notifier testing tool [Maze runner](https://github.com/bugsnag/maze-runner).
End to end tests are written in cucumber-style `.feature` files, and need Ruby-backed "steps" in order to know what to run. The tests are located in the top level [`test`](/test/) directory.
Maze runner's CLI and the test fixtures are containerised so you'll need Docker (and Docker Compose) to run them.
__Note: only Bugsnag employees can run the end-to-end tests.__ We have dedicated test infrastructure and private BrowserStack credentials which can't be shared outside of the organisation.
#### Authenticating with the private container registry
You'll need to set the credentials for the aws profile in order to access the private docker registry:
```
aws configure --profile=opensource
```
Subsequently you'll need to run the following command to authenticate with the registry:
```
npm run test:test-container-registry-login
```
__Your session will periodically expire__, so you'll need to run this command to re-authenticate when that happens.
For further details, see the `TESTING.md` for individual platforms:
- [Browser](./test/browser/TESTING.md)
- [Node](./test/node/TESTING.md)
- [React Native](./test/react-native/TESTING.md)
- [React Native CLI](./test/react-native-cli/TESTING.md)