Skip to content

Commit de06cd2

Browse files
authored
docs: fix mocha example (#1687)
* docs: fix broken mocha example * update readme * update package.json * revert test-examples.js * sync test-examples code to understand output * rerevert test-examples.js
1 parent 2118360 commit de06cd2

File tree

7 files changed

+52
-80
lines changed

7 files changed

+52
-80
lines changed

doc/examples/jasmine/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ result from HTML with a single error.
1010

1111
- Node must be installed; please follow the directions at http://www.nodejs.org
1212
to install it.
13-
- `npm install -g grunt-cli` to install the Grunt task runner (may need to be
14-
run with `sudo` on Unix or as Administrator on Windows)
1513
- Move to the `doc/examples/jasmine` directory
1614
- `npm install` to install dependencies
1715

1816
## To run the example
1917

2018
- Move to the `doc/examples/jasmine` directory
21-
- `grunt jasmine` to run Jasmine
19+
- `npm test` to run Jasmine
2220

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

doc/examples/mocha/Gruntfile.js

-16
This file was deleted.

doc/examples/mocha/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ result from HTML with a single error.
1010

1111
- Node must be installed; please follow the directions at http://www.nodejs.org
1212
to install it.
13-
- `npm install -g grunt-cli` to install the Grunt task runner (may need to be
14-
run with `sudo` on Unix or as Administrator on Windows)
1513
- Move to the `doc/examples/mocha` directory
1614
- `npm install` to install dependencies
1715

1816
## To run the example
1917

2018
- Move to the `doc/examples/mocha` directory
21-
- `grunt mocha` to run Mocha
19+
- `npm test` to run Mocha
2220

2321
You should see output indicating that the tests ran successfully, with zero
2422
failures.
@@ -33,5 +31,5 @@ to `axe.run`.
3331
The third argument to the `axe.run` call should be the function to test
3432
the results. The example is simply looking at the count of violations, but much
3533
more detailed information is available if desired. The axe documentation
36-
should be consulted for more details on customizing and
37-
analyzing calls to `axe.run`.
34+
should be consulted for more details on customizing and analyzing calls to
35+
`axe.run`.

doc/examples/mocha/karma.conf.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = function(config) {
2+
config.set({
3+
basePath: '',
4+
5+
frameworks: ['mocha', 'chai'],
6+
7+
files: ['test/**/*.js', 'node_modules/axe-core/axe.js'],
8+
9+
exclude: [],
10+
11+
preprocessors: {},
12+
13+
reporters: ['progress'],
14+
15+
port: 9876,
16+
17+
colors: true,
18+
19+
logLevel: config.LOG_INFO,
20+
21+
autoWatch: true,
22+
23+
browsers: ['ChromeHeadless'],
24+
25+
singleRun: true,
26+
27+
concurrency: Infinity
28+
});
29+
};

doc/examples/mocha/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
},
1111
"dependencies": {},
1212
"scripts": {
13-
"test": "grunt mocha"
13+
"test": "karma start karma.conf.js"
1414
},
1515
"devDependencies": {
1616
"axe-core": "^3.2.2",
17-
"chai": "~4.1.2",
18-
"grunt": "~1.0.2",
19-
"grunt-mocha": "1.2.0"
17+
"karma": "^4.1.0",
18+
"karma-chai": "^0.1.0",
19+
"karma-chrome-launcher": "^2.2.0",
20+
"karma-mocha": "^1.3.0"
2021
}
2122
}

doc/examples/mocha/test/a11y.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
/* global describe, it, expect, axe, document */
1+
/* global describe, it, expect, axe, document, expect */
22

33
describe('axe', function() {
4-
/* eslint no-unused-expressions: 0 */
54
'use strict';
65

6+
document
7+
.getElementsByTagName('body')[0]
8+
.insertAdjacentHTML(
9+
'beforeend',
10+
'<div id="working">' +
11+
'<label for="has-label">Label for this text field.</label>' +
12+
'<input type="text" id="has-label">' +
13+
'</div>' +
14+
'<div id="broken">' +
15+
'<p>Not a label</p><input type="text" id="no-label">' +
16+
'</div>'
17+
);
18+
719
it('should report that good HTML is good', function(done) {
820
var n = document.getElementById('working');
921
axe.run(n, function(err, result) {

doc/examples/mocha/test/test.html

-50
This file was deleted.

0 commit comments

Comments
 (0)