Skip to content

Latest commit

 

History

History
 
 

test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Material-UI Testing

Thanks for writing tests! Here's a quick run-down on our current setup.

Tools we use

Please familiarise yourself with these if you plan on contributing! 👍

Commands

Run unit and integration tests in node

npm run test

Run unit tests

npm run test unit or npm run test:unit

Watch unit tests

npm run test:unit:watch

Unit test a specific Component (also works with :watch)

-c / --component
npm run test:unit -- -c Avatar

Unit test with a mocha grep (also works with :watch)

-g / --grep
npm run test:unit -- -g "Grep this"

Integration tests

Same as unit tests but with :integration

Run all tests using Karma (if you like waiting for webpack)

npm run test:karma

Writing Tests

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.