All components should have, at minimum, unit tests for each prop. Please see the Jest unit test documentation for guidelines on testing best practices.
Cypress tests are optional and typically only written for more complex components, or where real-browser DOM and interactions are needed.
EUI is currently in the process of converting our Jest tests from Enzyme to React Testing Library, as Enzyme appears to have no intention of supporting React 17+.
EUI currently does not yet use Storybook to generate either snapshots or visual QA testing. However, plans are in the works to convert our current props snapshot tests to Storybook.
EUI currently does not use visual snapshots/screenshot regression testing or plans to implement visual diffing.
Code coverage is a tool intended to help devs quickly find lines/branches that still need to be covered and determine test cases to write. Currently, EUI does not yet use code coverage %s in CI for automated checks or reports.
Jest code coverage reports can be generated by running yarn test-unit
with the --coverage
flag. Generated HTML reports are output to the reports/
folder.
To view the reports, you can either drag the reports/jest-coverage/index.html
file into a browser window, or in a terminal, run open reports/jest-coverage/index.html
from the EUI project root.
Cypress has been configured to automatically output Cypress code coverage to the reports/cypress-coverage
folder. If you would prefer to turn this off locally, you can add the --env coverage=false
flag when running your your cypress commands.
To view the reports, you can either drag the reports/cypress-coverage/index.html
file into a browser window, or in a terminal, run open reports/cypress-coverage/index.html
from the EUI project root.
If you're working on a component that has both Cypress and Jest tests, we have a command that allows you to combine the results of both coverage reports.
- Setup: On the component(s) you're looking for final coverage #s for,
- Ensure you have already run
yarn test-unit --coverage
to generate a Jest report - Ensure you have already run
yarn test-cypress
to generate a Cypress report
- Run
yarn combine-test-coverage
- This should automatically open a browser window with
reports/combined-coverage/index.html