Sha256: 18a51f383c5ca0fd3f982606357c2995d4acadab7e31e5c126b222dde6626567

Contents?: true

Size: 1.73 KB

Versions: 271

Compression:

Stored size: 1.73 KB

Contents

# Jest + React README

This example demonstrates how to use axe to test React components using the
Jest unit testing framework.

The unit test is in `link.test.js`, and has one test cases, showing how to run
axe-core in Jest (using JSDOM and Enzyme).

## To configure the example

- Node must be installed; please follow the directions at http://www.nodejs.org
  to install it.
- Move to the `doc/examples/jest_react` directory
- `npm install` to install dependencies

## To run the example

- Move to the `doc/examples/jest_react` directory
- `npm test` to run Jasmine

You should see output indicating that the tests ran successfully, with zero
failures.

Note: to work better with JSDOM (which has limited support for necessary DOM APIs),
the color-contrast and link-in-text-block rules have been disabled in this example.
You can test for these rules more reliably using full browser DOM integration
testing using [axe-webdriverjs](https://github.com/dequelabs/axe-webdriverjs).

## To modify the example

This example can be modified to test components in other test frameworks as well. To use axe-core with JSDOM (Like Jest does), you will need to ensure that JSDOM variables are made available on the global object. An easy way to do this is to use [jsdom-global](https://github.com/rstacruz/jsdom-global).

For example, when running Mocha, you should require `jsdom-global/register`. The command for this is as follows:

```sh
mocha *.test.js --require jsdom-global/register
```

## Timeout Issues

Axe-core is very fast for what it does, but when testing larger components, it may take a few seconds to complete. This is because axe will be running thousands of tests in a single call. When testing composite components, you may have to increase the timeout setting.

Version data entries

271 entries across 271 versions & 1 rubygems

Version Path
govuk_publishing_components-30.4.1 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.4.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.3.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.2.1 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.2.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.1.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-30.0.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.15.3 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.15.2 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.15.1 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.15.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.14.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.13.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.12.1 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.12.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.11.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.10.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.9.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.8.0 node_modules/axe-core/doc/examples/jest_react/README.md
govuk_publishing_components-29.7.0 node_modules/axe-core/doc/examples/jest_react/README.md