Skip to content

Commit

Permalink
Update Cypress README and configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrunet committed Sep 26, 2023
1 parent a65f2dd commit 145bc53
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 87 deletions.
25 changes: 16 additions & 9 deletions cypress-accessibility-checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The plugin works by injecting the automated accessibility-checker testing into [
## Requirements

* [Node Version 18](https://nodejs.org/en/download/)
* Cypress 12
* Cypress 13

## Installation

Expand All @@ -27,25 +27,32 @@ There are two setup steps you must complete in order for the Cypress tests to be

### 1. Add plugin

In the `cypress/plugins/index.js` file located in your project, require the plugin and then register it with Cypress.
In the Cypress config for your project, require the plugin and then register it with Cypress.

```js
const aCheckerTasks = require('cypress-accessibility-checker/plugin');
module.exports = (on, config) => {
on('task', {
accessibilityChecker: aCheckerTasks
});
};
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', {
accessibilityChecker: require('cypress-accessibility-checker/plugin')
});
}
}
})
```

### 2. Import commands

In the `cypress/support/index.js` file located in your project, add the following import statement. This will import the accessibility checker commands and register them with Cypress.
In the `cypress/support/e2e.js` file located in your project, add the following import statement. This will import the accessibility checker commands and register them with Cypress.

```js
import 'cypress-accessibility-checker';
```

If you do not want to include `cypress-accessibility-checker` globally, you may instead add this import statement to every test file in which it is used.

## Usage

The commands maps directly to the description of the APIs located [in the accessibility-checker/src/README](https://github.com/IBMa/equal-access/blob/master/accessibility-checker/src/README.md). The names of the APIs within Cypress are just slightly different so they are globally unique in the Cypress namespace.
Expand Down
8 changes: 4 additions & 4 deletions cypress-accessibility-checker/boilerplates/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
on('task', {
accessibilityChecker: require('cypress-accessibility-checker/plugin')
});
},
baseUrl: 'http://localhost:8080/sample-html',
supportFile: false
},
}
})

This file was deleted.

4 changes: 3 additions & 1 deletion cypress-accessibility-checker/test/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
on('task', {
accessibilityChecker: require('../plugin')
});
},
baseUrl: 'http://localhost:8080/test/sample-html',
},
Expand Down
37 changes: 0 additions & 37 deletions cypress-accessibility-checker/test/cypress/plugins/index.js

This file was deleted.

0 comments on commit 145bc53

Please sign in to comment.