Thanks for writing tests! Here's a quick run-down on our current setup.
Please familiarise yourself with these if you plan on contributing! 👍
npm run test
npm run test unit
or npm run test:unit
npm run test:unit:watch
-c
/ --component
npm run test:unit -- -c Avatar
-g
/ --grep
npm run test:unit -- -g "Grep this"
Same as unit tests but with :integration
npm run test:karma
For all unit tests, please use the shallow renderer from enzyme
unless the Component being tested requires a DOM. Here's a small shallow rendered test to get you started.
If the Component being unit tested requires a DOM, you can use the mount api from enzyme
. For some operations you may still need to use the React test utils, but try to use the enzyme
API as much as possible.
Stick to test assertions such as assert.strictEqual
and assert.ok
. This helps keep tests simple and readable.