Skip to content

Commit

Permalink
feat(puppeteer): support puppeteer v9 (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Mathieson <me@stephenmathieson.com>
  • Loading branch information
michael-siek and stephenmathieson committed May 4, 2021
1 parent 4e8f7fe commit 753a919
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 52 deletions.
138 changes: 95 additions & 43 deletions packages/puppeteer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
"express": "^4.16.4",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"puppeteer": "^5.3.1",
"puppeteer": "^9",
"sinon": "^7.3.2",
"source-map-support": "^0.5.9",
"test-listen": "^1.1.0",
"ts-node": "^8.3.0",
"typescript": "^3.1.6"
"typescript": "^4.2.4"
},
"dependencies": {
"axe-core": "^4.2.0"
},
"peerDependencies": {
"puppeteer": ">=1.10.0 < 6"
"puppeteer": ">=1.10.0 < 9"
},
"engines": {
"node": ">=6.4.0"
Expand Down
12 changes: 7 additions & 5 deletions packages/puppeteer/src/axePuppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ interface IInjectAxeArgs {
args?: any[];
}

function injectJSModule(frame: Frame): Promise<void> {
return frame.addScriptTag({
path: require.resolve('axe-core')
});
function injectJSModule(frame: Frame): Promise<ElementHandle<Element> | void> {
return frame
.addScriptTag({
path: require.resolve('axe-core')
})
.then(() => undefined);
}

function injectJSSource(
Expand Down Expand Up @@ -56,7 +58,7 @@ async function injectJS(
console.error(`Failed to inject axe-core into frame (${frame.url()})`);
};

let injectP: Promise<void>;
let injectP: Promise<ElementHandle<Element> | void>;
if (!source) {
injectP = injectJSModule(frame);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/puppeteer/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function pageIsLoaded(): boolean {
return document.readyState === 'complete';
}

export function configureAxe(config?: Axe.Spec) {
export function configureAxe(config?: Axe.Spec): void {
if (config) {
window.axe.configure(config);
}
Expand Down

0 comments on commit 753a919

Please sign in to comment.