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

fix(webdriverjs): Reject with actual Errors (not strings) #423

Merged
merged 3 commits into from
Jan 25, 2022
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
12 changes: 6 additions & 6 deletions packages/cli/src/lib/axe-test-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const testPages = async (
.get(currentUrl)
.then(() => {
return driver.executeAsyncScript(`
const callback = arguments[arguments.length - 1];
const script = document.createElement('script');
script.innerHTML = 'document.documentElement.classList.add("deque-axe-is-ready");'
document.documentElement.appendChild(script);
callback();
const callback = arguments[arguments.length - 1];
const script = document.createElement('script');
script.innerHTML = 'document.documentElement.classList.add("deque-axe-is-ready");'
document.documentElement.appendChild(script);
callback();
`);
})
.then(() => {
Expand Down Expand Up @@ -84,7 +84,7 @@ const testPages = async (
events?.startTimer('axe-core execution time');
}

axe.analyze((err: string, results: AxeResults) => {
axe.analyze((err: Error | null, results: AxeResults) => {
if (config.timer) {
events?.endTimer('axe-core execution time');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AxeResults } from 'axe-core';
import type { WebDriver, Builder } from 'selenium-webdriver';
import type { Options } from 'selenium-webdriver/chrome';

export interface EventParams {
silentMode: boolean;
timer: boolean;
Expand Down
9 changes: 2 additions & 7 deletions packages/webdriverjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { WebDriver } from 'selenium-webdriver';
import { RunOptions, Spec, AxeResults, ContextObject } from 'axe-core';
import { source } from 'axe-core';
import {
CallbackFunction,
BuilderOptions,
PartialResults,
Selector
} from './types';
import { CallbackFunction, BuilderOptions, Selector } from './types';
import { normalizeContext } from './utils/index';
import AxeInjector from './axe-injector';
import {
Expand Down Expand Up @@ -136,7 +131,7 @@ class AxeBuilder {
.catch((err: Error) => {
// When using a callback, do *not* reject the wrapping Promise. This prevents having to handle the same error twice.
if (callback) {
callback(err.message, null);
callback(err, null);
} else {
reject(err);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webdriverjs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface AxeInjectorParams extends Options {
}

export type CallbackFunction = (
error: string | null,
error: Error | null,
results: AxeResults | null
) => void;

Expand Down