GlueStick sets up a testing environment using Jest and Enzyme.
To add tests, create a file in any __tests__
directory with the extension .test.js
and its tests
will be executed through the test runner using:
npm test
The convention is colocate your __tests__
folder with the file it’s testing, and use the same
naming for tests as the files that they test.
- src
- components
- MyComponent.js
- __tests__
- MyComponent.test.js
Tests can also be typed using Flow
(see below). We use flow-typed for Jest under the hood.
If you're using node 8.4.0+ you can also debug you test - just add -D
:
gluestick test -D
Then you can use, for instance, Node.js V8 --inspector Manager (NiM) to debug them in Chrome.
We recommend adding "sourceMaps": "inline"
to your .babelrc
for better developer experience.
All generated files will use /* flow */
and will be typed.
We recommend you to do the same for your own files. To run flow just run:
npm run flow
There is a predefined linting configuration (following airbnb config) for your project. Run it using:
npm run lint
All of the above code quality commands can be executed simultaneously by:
npm run ci
You can read more about environment details here.