Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: test axe examples in ci #1437

Merged
merged 4 commits into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ jobs:
- phantomjs
- run: npm run test

# Run examples under `doc/examples`
test_examples:
<<: *defaults
steps:
- checkout
- run: npm run test:examples

# Release a "next" version
next_release:
<<: *defaults
Expand Down Expand Up @@ -92,11 +99,13 @@ workflows:
requires:
- dependencies
- lint
- test_examples
scurker marked this conversation as resolved.
Show resolved Hide resolved
# Hold for approval
- hold:
type: approval
requires:
- test
- test_examples
filters:
# We only want to hold on these two branches, as PR review acts as approval for PRs
branches:
Expand All @@ -108,6 +117,7 @@ workflows:
requires:
- dependencies
- test
- test_examples
- hold
filters:
branches:
Expand All @@ -117,6 +127,7 @@ workflows:
requires:
- dependencies
- test
- test_examples
- hold
filters:
branches:
Expand Down
20 changes: 20 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 1.0.{build}-{branch}
scurker marked this conversation as resolved.
Show resolved Hide resolved

# Test against this version of node.
environment:
nodejs_version: "10"
skip_tags: true

# Install scripts. (runs after repo cloning)
install:
- ps: Install-Product node $env:nodejs_version
- npm install

# Post-install test scripts.
test_script:
- node --version
- npm --version
- npm run test:examples

# Don't actually build.
build: off
7 changes: 5 additions & 2 deletions doc/examples/chrome-debugging-protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "axe-cdp",
"private": true,
"scripts": {
"test": "echo 'No test specified.'"
},
"dependencies": {
"axe-core": "^3.1.1",
"chrome-remote-interface": "^0.26.0"
"axe-core": "^3.2.2",
"chrome-remote-interface": "^0.27.1"
}
}
16 changes: 0 additions & 16 deletions doc/examples/jasmine/Gruntfile.js

This file was deleted.

51 changes: 51 additions & 0 deletions doc/examples/jasmine/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Karma configuration
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
scurker marked this conversation as resolved.
Show resolved Hide resolved
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: ['spec/**/*.js', 'node_modules/axe-core/axe.js'],

// list of files / patterns to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};
9 changes: 5 additions & 4 deletions doc/examples/jasmine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
},
"dependencies": {},
"scripts": {
"test": "grunt jasmine"
"test": "karma start karma.conf.js"
},
"devDependencies": {
"axe-core": "^3.1.1",
"grunt": "~1.0.2",
"grunt-contrib-jasmine": "~2.0.0"
"axe-core": "^3.2.2",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-jasmine": "^2.0.1"
}
}
2 changes: 1 addition & 1 deletion doc/examples/jest_react/link.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import axe from 'axe-core';
import { mountToDoc } from './test-helpers';

import Link from './Link';
import Link from './link';

test('Link has no aXe violations', done => {
const linkComponent = mountToDoc(
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/jest_react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "jest"
},
"devDependencies": {
"axe-core": "^3.1.1",
"axe-core": "^3.2.2",
scurker marked this conversation as resolved.
Show resolved Hide resolved
"babel-jest": "^23.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "grunt mocha"
},
"devDependencies": {
"axe-core": "^3.1.1",
"axe-core": "^3.2.2",
"chai": "~4.1.2",
"grunt": "~1.0.2",
"grunt-mocha": "1.2.0"
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/phantomjs/axe-phantom.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ page.open(args[1], function(status) {
page.switchToMainFrame();
page.evaluateAsync(function() {
/*global axe */
axe.run(function(err, results) {
axe.run({ include: ['#page'] }, function(err, results) {
if (err) {
throw err;
}
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/phantomjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axe-phantomjs-example",
"description": "aXe Mocha Example",
"description": "aXe PhantomJS Example",
"version": "0.0.1",
"private": true,
"author": {
Expand All @@ -10,10 +10,10 @@
},
"dependencies": {},
"scripts": {
"test": "phantomjs axe-phantom.js http://www.deque.com"
"test": "phantomjs axe-phantom.js https://www.deque.com"
},
"devDependencies": {
"axe-core": "^3.1.1",
"axe-core": "^3.2.2",
"phantomjs": "^2.1.7"
}
}
5 changes: 4 additions & 1 deletion doc/examples/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"version": "0.0.0",
"private": true,
"main": "axe-puppeteer.js",
"scripts": {
"test": "node axe-puppeteer.js https://deque.com"
},
"dependencies": {
"axe-core": "^3.1.1",
"axe-core": "^3.2.2",
"puppeteer": "^1.6.0"
}
}
2 changes: 1 addition & 1 deletion doc/examples/qunit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "grunt qunit"
},
"devDependencies": {
"axe-core": "^3.1.1",
"axe-core": "^3.2.2",
"grunt": "~1.0.2",
"grunt-contrib-qunit": "~3.1.0",
"qunitjs": "~2.4.1"
Expand Down
36 changes: 36 additions & 0 deletions doc/examples/test-examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { readdirSync, statSync } = require('fs');
const { join } = require('path');
const { spawn } = require('child_process');
const exampleDirs = readdirSync(__dirname)
.map(dir => join(__dirname, dir))
.filter(dir => statSync(dir).isDirectory());

async function runner(dir) {
scurker marked this conversation as resolved.
Show resolved Hide resolved
let child = spawn('npm install && npm test', {
scurker marked this conversation as resolved.
Show resolved Hide resolved
cwd: dir,
shell: true,
stdio: 'inherit'
});

return new Promise((resolve, reject) => {
scurker marked this conversation as resolved.
Show resolved Hide resolved
child.on('close', code => {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
}

(async () => {
await Promise.all(exampleDirs.map(runner))
scurker marked this conversation as resolved.
Show resolved Hide resolved
.then(() => {
// Return successful exit
process.exit();
})
.catch(err => {
console.log(err);
scurker marked this conversation as resolved.
Show resolved Hide resolved
process.exit(1);
});
})();
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
"build": "grunt",
"eslint": "eslint --color --format stylish '{lib,test,build,doc}/**/*.js' 'Gruntfile.js'",
"test": "npm run retire && tsc && grunt test",
"test:examples": "node ./doc/examples/test-examples",
"version": "echo \"use 'npm run release' to bump axe-core version\" && exit 1",
"prepublishOnly": "grunt build && grunt file-exists",
"retire": "retire --jspath 'lib' --nodepath './' --ignorefile '.retireignore.json' --severity 'medium'",
"retire": "retire --jspath lib --nodepath ./ --ignorefile .retireignore.json --severity medium",
"release": "standard-version -a",
"rule-gen": "node build/rule-generator",
"next-release": "standard-version --scripts.prebump=./build/next-version.js --skip.commit=true --skip.tag=true",
Expand Down