-{"description":"\n## Testing\n\nThis page provides an overview of the testing strategies we use to ensure the quality and stability of our components. We use a combination of modern tools to support our testing needs. Each tool serves a different purpose in our testing pyramid.\n\n### Test strategies:\n\n#### Unit tests with Vitest and React Testing Library:\n\nThese tools are our primary stack for writing component-level unit tests. They are lightweight and fast. [Vitest](https://vitest.dev/guide/) is one of the fastest modern testing framework. It offers a Jest-like API and runs in a Node.js environment, making it ideal for testing individual components and functions in isolation. Paired with [React Testing Library](https://testing-library.com/docs/react-testing-library/intro), Vitest encourages accessible and maintainable test practices by querying elements the way users interact with them. It's best suited for testing component logic, rendering conditions, and props/state changes without needing a full browser environment.\n\nFor more information about our unit tests you can check out our [detailed guides and examples.](/#vitest-unit-testing)\n\n#### Component Testing with Cypress:\n\n[Cypress Component Testing](https://docs.cypress.io/app/component-testing/get-started) allows us to mount individual components in a real browser environment for precise interaction testing. Unlike traditional unit tests, it renders with full CSS and browser APIs, offering more realistic behavior. This makes it ideal for testing user interactions like clicks, keyboard navigation, focus traps, and animations. While a bit heavier than Vitest, it provides greate visibility and debugging capabilities for complex UI logic.\n\nFor more information check out our [detailed guides and examples.](cypress-component-testing)\n\n#### Visual Regression Testing with Cypress and Chromatic:\n\nWe use [Cypress](https://docs.cypress.io/app/tooling/visual-testing) end-to-end (e2e) tests to generate structured layouts and capture screenshots of components. [Chromatic](https://www.chromatic.com/docs/diff-inspector/) handles the visual diffing and review process. It's especially effective for catching layout shifts, styling regressions, or broken UI elements that don’t trigger functional test failures. Tests are run after changes are pushed to remote, comparing the new screenshots to a baseline stored from a previously verified state. When differences are detected, the test fails and provides side-by-side diffs for easy review.\n\nThese e2e tests also run [Axe](https://github.com/dequelabs/axe-core) accessibility checks and monitors `console.error`s.\n\nYou can read about these in the [README](https://github.com/instructure/instructure-ui/blob/master/regression-test/README.md) of the regression testing suite.\n","title":"Testing","category":"Contributor Guides/Testing","order":1,"relativePath":"docs/testing/testing-overview.md","extension":".md","srcPath":"docs/testing/testing-overview.md","srcUrl":"https://github.com/instructure/instructure-ui/tree/master/docs/testing/testing-overview.md","packageName":"@instructure/docs","requirePath":"@instructure/docs/testing/testing-overview","requireStr":"require('/home/runner/work/instructure-ui/instructure-ui/docs/testing/testing-overview.md').default","esPath":"@instructure/docs/testing/testing-overview","themePath":"docs/testing/testing-overview.md","themeUrl":"https://github.com/instructure/instructure-ui/tree/master/docs/testing/testing-overview.md","id":"testing-overview"}
0 commit comments