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

feat: add @axe-core/webdriverio #15

Merged
merged 16 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- restore_cache:
keys:
- v1-webdriverjs-npm-{{ checksum "packages/webdriverjs/package-lock.json" }}
- restore_cache:
keys:
- v1-webdriverio-npm-{{ checksum "packages/webdriverio/package-lock.json" }}
- run: npm ci
- save_cache:
key: v1-root-npm-{{ checksum "package-lock.json" }}
Expand All @@ -54,13 +57,18 @@ jobs:
key: v1-webdriverjs-npm-{{ checksum "packages/webdriverjs/package-lock.json" }}
paths:
- packages/webdriverjs/node_modules
- save_cache:
key: v1-webdriverio-npm-{{ checksum "packages/webdriverio/package-lock.json" }}
paths:
- packages/webdriverio/node_modules
- save_cache:
key: v1-npm-cache-{{ .Environment.CIRCLE_SHA1 }}
paths:
- node_modules
- packages/cli/node_modules
- packages/puppeteer/node_modules
- packages/webdriverjs/node_modules
- packages/webdriverio/node_modules

lint:
<<: *defaults
Expand Down Expand Up @@ -91,6 +99,13 @@ jobs:
- restore_dependency_cache
- run: npm run test --prefix=packages/webdriverjs

webdriverio:
<<: *defaults
steps:
- checkout
- restore_dependency_cache
- run: npm run test --prefix=packages/webdriverio

workflows:
version: 2
build_and_test:
Expand All @@ -108,3 +123,6 @@ workflows:
- webdriverjs:
requires:
- lint
- webdriverio:
requires:
- lint
15 changes: 15 additions & 0 deletions packages/webdriverio/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
rules: {
'@typescript-eslint/no-empty-function': 'off',
'prefer-spread': 'off',
'prefer-rest-params': 'off'
},
overrides: [
{
files: 'tests/**/*.js',
env: {
jest: true
}
}
]
};
5 changes: 5 additions & 0 deletions packages/webdriverio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @axe-core/webdriverio

Provides bindings for axe with webdriverio

Previous versions of this program were maintained at [dequelabs/axe-webdriverio](https://github.com/dequelabs/axe-webdriverio).
51 changes: 51 additions & 0 deletions packages/webdriverio/lib/bindings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = function bind(driver) {
const webdriver = driver;

if (
typeof webdriver.executeScript !== 'function' &&
typeof webdriver.execute === 'function'
) {
webdriver.executeScript = function executeScript() {
return this.execute.apply(this, arguments);
}.bind(webdriver);
}

if (
typeof webdriver.executeAsyncScript !== 'function' &&
typeof webdriver.executeAsync === 'function'
) {
webdriver.executeAsyncScript = function executeAsyncScript() {
return this.executeAsync.apply(this, arguments);
}.bind(webdriver);
}

if (
typeof webdriver.switchTo !== 'function' &&
typeof webdriver.frame === 'function'
) {
webdriver.switchTo = function switchTo() {
return {
window: function window() {
return this.window.apply(this, arguments);
}.bind(this),
frame: function frame() {
return this.frame.apply(this, arguments);
}.bind(this),
defaultContent: function defaultContent() {
return this.frame.apply(this, null);
}.bind(this)
};
}.bind(webdriver);
}

if (
typeof webdriver.findElements !== 'function' &&
typeof webdriver.elements === 'function'
) {
webdriver.findElements = function findElements(selector) {
return webdriver.elements(`<${selector.tagName}>`);
}.bind(webdriver);
}

return webdriver;
};
4 changes: 4 additions & 0 deletions packages/webdriverio/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '@axe-core/webdriverio' {
export * from '@axe-core/webdriverjs';
export { AxeBuilder as AxeWebDriverIOBuilder } from '@axe-core/webdriverjs';
}
10 changes: 10 additions & 0 deletions packages/webdriverio/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const AxeBuilder = require('@axe-core/webdriverjs');
const bindings = require('./bindings');

class AxeWebDriverIOBuilder extends AxeBuilder {
constructor(driver, source) {
super(bindings(driver), source);
}
}

module.exports = AxeWebDriverIOBuilder;
Loading