Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9682bb6

Browse files
committedJul 31, 2015
Build: add accessibility testing
Fixes jquery-archive#99
1 parent 6a9565e commit 9682bb6

File tree

8 files changed

+108
-36
lines changed

8 files changed

+108
-36
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ external/
1010
icons/svg-min/
1111
.sass-cache/
1212
dist/
13+
tmp/

‎Gruntfile.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module.exports = function( grunt ) {
2-
var path = require( "path" );
3-
require( "load-grunt-config" )( grunt, {
4-
configPath: [
5-
path.join( process.cwd(), "tasks/options" ),
6-
path.join( process.cwd(), "tasks" )
7-
],
8-
init: true
9-
} );
2+
grunt.loadNpmTasks("axe-grunt-webdriver");
3+
var path = require( "path" );
4+
require( "load-grunt-config" )( grunt, {
5+
configPath: [
6+
path.join( process.cwd(), "tasks/options" ),
7+
path.join( process.cwd(), "tasks" )
8+
],
9+
init: true
10+
} );
1011
};

‎demos/typography.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html>
2+
<html lang="en">
33
<head>
44
<meta charset="utf-8">
55
<title>CSS Chassis - Typography</title>

‎lib/reporter.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
3+
function color(code, str) {
4+
return "\u001b[" + code + "m" + str + "\u001b[0m";
5+
}
6+
7+
exports = module.exports = function( grunt, results, threshold ) {
8+
var pass = true;
9+
results.forEach( function ( result ) {
10+
grunt.log.subhead( result.url );
11+
var violations = result.violations;
12+
if ( violations.length ) {
13+
if ( violations.length > threshold ) {
14+
pass = false;
15+
grunt.log.error( "Found " + result.violations.length + " accessibility violations:" );
16+
} else {
17+
grunt.log.ok( "Found " + result.violations.length + " accessibility violations: (under threshold of " + threshold + ")" );
18+
}
19+
result.violations.forEach( function( ruleResult ) {
20+
grunt.log.subhead( " " + color(31, "\u00D7") + " " + ruleResult.help );
21+
22+
ruleResult.nodes.forEach( function( violation, index ) {
23+
grunt.log.writeln( " " + ( index + 1 ) + ". " + JSON.stringify( violation.target ) );
24+
25+
if ( violation.any.length ) {
26+
grunt.log.writeln( " Fix any of the following:" );
27+
violation.any.forEach( function( check ) {
28+
grunt.log.writeln( " \u2022 " + check.message );
29+
} );
30+
}
31+
32+
var alls = violation.all.concat( violation.none );
33+
if ( alls.length ) {
34+
grunt.log.writeln( " Fix all of the following:" );
35+
alls.forEach( function( check ) {
36+
grunt.log.writeln( " \u2022 " + check.message );
37+
} );
38+
}
39+
grunt.log.writeln();
40+
});
41+
});
42+
return;
43+
} else {
44+
grunt.log.ok( "Found no accessibility violations." );
45+
}
46+
} );
47+
return pass;
48+
};

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@
3737
},
3838
"dependencies": {},
3939
"devDependencies": {
40+
"axe-grunt-webdriver": "0.0.1",
4041
"browser-perf": "1.2.3",
4142
"chromedriver": "2.13.0",
4243
"commitplease": "2.0.0",
4344
"ejs-template": "0.1.0",
4445
"grunt": "0.4.5",
4546
"grunt-autoprefixer": "2.1.0",
46-
"grunt-contrib-cssmin": "0.10.0",
47+
"grunt-contrib-connect": "0.9.0",
4748
"grunt-contrib-csslint": "0.4.0",
49+
"grunt-contrib-cssmin": "0.10.0",
4850
"grunt-contrib-jshint": "0.10.0",
49-
"grunt-contrib-connect": "0.9.0",
5051
"grunt-contrib-watch": "0.6.1",
5152
"grunt-csscomb": "3.0.0",
5253
"grunt-git-authors": "2.0.0",

‎tasks/alias.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = function( grunt ) {
22
grunt.registerTask( "default", [ "test" ] );
3-
grunt.registerTask( "test", [ "build", "jshint", "jscs", "csslint" ] );
4-
grunt.registerTask( "build", [ "svg", "sass", "csscomb", "cssmin" ] );
3+
grunt.registerTask( "accessibility", [ "connect:accessibility", "axe-webdriver"])
4+
grunt.registerTask( "test", [ "build", "jshint", "jscs", "csslint", "accessibility" ] );
5+
grunt.registerTask( "build", [ "buildVariables", "svg", "sass", "csscomb", "cssmin" ] );
56
grunt.registerTask( "perf", [
67
"start-selenium-server",
78
"connect:perf",

‎tasks/options/axe-webdriver.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
firefox: {
3+
options: {
4+
threshold: 0
5+
},
6+
urls: ['http://localhost:4200/demos/typography.html'],
7+
dest: 'tmp/gu.json'
8+
},
9+
chrome: {
10+
options: {
11+
browser: 'chrome',
12+
threshold: 0
13+
},
14+
urls: ['http://localhost:4200/demos/typography.html']
15+
}
16+
};

‎tasks/options/connect.js

+27-23
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,36 @@ var template = require( "ejs-template" ),
55
module.exports = {
66
options: {
77
port: 4200,
8-
base: ".",
9-
middleware: [
10-
template.middleware({ basedir: __dirname }),
11-
function( req, res ) {
12-
var data, i,
13-
url = urlParser.parse( req.url, true ),
14-
query = {},
15-
parts = url.pathname.split( "/" ),
16-
file = req.url.replace( /^\//, "" ).split( "?" )[ 0 ];
8+
base: "."
9+
},
10+
perf: {
11+
options: {
12+
middleware: [
13+
template.middleware({ basedir: __dirname }),
14+
function( req, res ) {
15+
var data, i,
16+
url = urlParser.parse( req.url, true ),
17+
query = {},
18+
parts = url.pathname.split( "/" ),
19+
file = req.url.replace( /^\//, "" ).split( "?" )[ 0 ];
1720

18-
for ( i = 1; i < parts.length; i += 2 ) {
19-
query[ parts[ i ] ] = parts[ i + 1 ];
21+
for ( i = 1; i < parts.length; i += 2 ) {
22+
query[ parts[ i ] ] = parts[ i + 1 ];
23+
}
24+
if ( file.split( "." ).length <= 1 ) {
25+
data = componentGenerator.generate(
26+
query.framework,
27+
query.component,
28+
query.count
29+
);
30+
file = "../../performance/component.html";
31+
}
32+
res.endTemplate( file, data );
2033
}
21-
if ( file.split( "." ).length <= 1 ) {
22-
data = componentGenerator.generate(
23-
query.framework,
24-
query.component,
25-
query.count
26-
);
27-
file = "../../performance/component.html";
28-
}
29-
res.endTemplate( file, data );
30-
}
31-
]
34+
]
35+
}
3236
},
33-
perf: {},
37+
accessibility: {},
3438
dev: {
3539
options: {
3640
keepalive: true

0 commit comments

Comments
 (0)
Please sign in to comment.