@axe-core/playwright
Advanced tools
Comparing version 4.3.2 to 4.3.3-alpha.218
@@ -38,6 +38,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -51,3 +55,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
this.childRunners = []; | ||
this.partialPromise = exports.caught(partialPromise); | ||
this.partialPromise = (0, exports.caught)(partialPromise); | ||
} | ||
@@ -68,3 +72,3 @@ AxePartialRunner.prototype.addChildResults = function (childResultRunner) { | ||
childPromises = this.childRunners.map(function (childRunner) { | ||
return childRunner ? exports.caught(childRunner.getPartials()) : [null]; | ||
return childRunner ? (0, exports.caught)(childRunner.getPartials()) : [null]; | ||
}); | ||
@@ -74,3 +78,3 @@ return [4 /*yield*/, Promise.all(childPromises)]; | ||
childPartials = (_a.sent()).flat(1); | ||
return [2 /*return*/, __spreadArray([parentPartial], childPartials)]; | ||
return [2 /*return*/, __spreadArray([parentPartial], childPartials, true)]; | ||
case 3: | ||
@@ -77,0 +81,0 @@ e_1 = _a.sent(); |
@@ -17,3 +17,3 @@ import type { RunOptions, AxeResults } from 'axe-core'; | ||
*/ | ||
include(selector: string): this; | ||
include(selector: string | string[]): this; | ||
/** | ||
@@ -25,3 +25,3 @@ * Selector to exclude in analysis. | ||
*/ | ||
exclude(selector: string): this; | ||
exclude(selector: string | string[]): this; | ||
/** | ||
@@ -28,0 +28,0 @@ * Set options to be passed into axe-core |
@@ -63,2 +63,3 @@ "use strict"; | ||
AxeBuilder.prototype.include = function (selector) { | ||
selector = Array.isArray(selector) ? selector : [selector]; | ||
this.includes.push(selector); | ||
@@ -74,2 +75,3 @@ return this; | ||
AxeBuilder.prototype.exclude = function (selector) { | ||
selector = Array.isArray(selector) ? selector : [selector]; | ||
this.excludes.push(selector); | ||
@@ -157,3 +159,3 @@ return this; | ||
case 0: | ||
context = utils_1.normalizeContext(this.includes, this.excludes); | ||
context = (0, utils_1.normalizeContext)(this.includes, this.excludes); | ||
_a = this, page = _a.page, options = _a.option; | ||
@@ -160,0 +162,0 @@ page.evaluate(this.script()); |
@@ -9,3 +9,3 @@ import type { ContextObject } from 'axe-core'; | ||
*/ | ||
export declare const normalizeContext: (includes: string[], excludes: string[]) => ContextObject; | ||
export declare const normalizeContext: (includes: string[][], excludes: string[][]) => ContextObject; | ||
/** | ||
@@ -12,0 +12,0 @@ * Analyze the page. |
{ | ||
"name": "@axe-core/playwright", | ||
"version": "4.3.2", | ||
"version": "4.3.3-alpha.218+0372686", | ||
"description": "Provides a method to inject and analyze web pages using axe", | ||
@@ -39,10 +39,10 @@ "contributors": [ | ||
"dependencies": { | ||
"axe-core": "^4.3.3", | ||
"playwright": "^1.13.1" | ||
"axe-core": "^4.3.5", | ||
"playwright": "^1.16.2" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.21", | ||
"@types/chai": "^4.2.22", | ||
"@types/express": "^4.17.13", | ||
"@types/mocha": "^8.2.3", | ||
"@types/node": "^14.17.9", | ||
"@types/node": "^14.17.32", | ||
"@types/test-listen": "^1.1.0", | ||
@@ -57,3 +57,3 @@ "axe-test-fixtures": "github:dequelabs/axe-test-fixtures#v1", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.3.5" | ||
"typescript": "^4.4.4" | ||
}, | ||
@@ -82,3 +82,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "ad34c79d557ed9e63493be3fa5dc7ded409b943f" | ||
"gitHead": "037268640c2007156657bf67e344116e36cb48e6" | ||
} |
@@ -86,3 +86,3 @@ # @axe-core/playwright | ||
### AxeBuilder#include(selector: String) | ||
### AxeBuilder#include(selector: String | String[]) | ||
@@ -95,4 +95,15 @@ Adds a CSS selector to the list of elements to include in analysis | ||
### AxeBuilder#exclude(selector: String) | ||
Method chaining is also available, add multiple CSS selectors to the list of elements to include in analysis | ||
```js | ||
new AxeBuilder({ page }) | ||
.include('.selector-one') | ||
.include('.selector-two') | ||
.include('.selector-three'); | ||
``` | ||
Note: arrays with more than one index when passing multiple CSS selectors are not currently supported example: ` .include(['#foo', '#bar', '#baz'])` | ||
### AxeBuilder#exclude(selector: String | String[]) | ||
Add a CSS selector to the list of elements to exclude from analysis | ||
@@ -104,2 +115,13 @@ | ||
Method chaining is also available, add multiple CSS selectors to the list of elements to exclude from analysis | ||
```js | ||
new AxeBuilder({ page }) | ||
.exclude('.selector-one') | ||
.exclude('.selector-two') | ||
.exclude('.selector-three'); | ||
``` | ||
Note: arrays with more than one index when passing multiple CSS selectors are not currently supported example: ` .exclude(['#foo', '#bar', '#baz'])` | ||
### AxeBuilder#options(options: [axe.RunOptions](https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#options-parameter)) | ||
@@ -106,0 +128,0 @@ |
@@ -22,4 +22,4 @@ import * as fs from 'fs'; | ||
private page: Page; | ||
private includes: string[]; | ||
private excludes: string[]; | ||
private includes: string[][]; | ||
private excludes: string[][]; | ||
private option: RunOptions; | ||
@@ -46,3 +46,4 @@ private source: string; | ||
public include(selector: string): this { | ||
public include(selector: string | string[]): this { | ||
selector = Array.isArray(selector) ? selector : [selector]; | ||
this.includes.push(selector); | ||
@@ -59,3 +60,4 @@ return this; | ||
public exclude(selector: string): this { | ||
public exclude(selector: string | string[]): this { | ||
selector = Array.isArray(selector) ? selector : [selector]; | ||
this.excludes.push(selector); | ||
@@ -173,3 +175,5 @@ return this; | ||
throw new Error( | ||
`${error.message}\n Please check out https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/error-handling.md` | ||
`${ | ||
(error as Error).message | ||
}\n Please check out https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/error-handling.md` | ||
); | ||
@@ -176,0 +180,0 @@ } |
@@ -12,4 +12,4 @@ import type { AxeResults, ContextObject } from 'axe-core'; | ||
export const normalizeContext = ( | ||
includes: string[], | ||
excludes: string[] | ||
includes: string[][], | ||
excludes: string[][] | ||
): ContextObject => { | ||
@@ -16,0 +16,0 @@ const base: ContextObject = { |
@@ -131,3 +131,3 @@ import 'mocha'; | ||
} catch (e) { | ||
error = e; | ||
error = e as Error; | ||
} | ||
@@ -147,3 +147,3 @@ assert.isNotNull(error); | ||
} catch (e) { | ||
error = e; | ||
error = e as Error; | ||
} | ||
@@ -418,2 +418,91 @@ | ||
}); | ||
it('with chaining includes', async () => { | ||
await page.goto(`${addr}/context.html`); | ||
const results = await new AxeBuilder({ page }) | ||
.include('.include') | ||
.include('.include2') | ||
.analyze(); | ||
const flattenTarget = flatPassesTargets(results); | ||
assert.strictEqual(flattenTarget[0], '.include'); | ||
assert.strictEqual(flattenTarget[1], '.include2'); | ||
assert.notInclude(flattenTarget, '.exclude'); | ||
assert.notInclude(flattenTarget, '.exclude2'); | ||
}); | ||
it('with chaining excludes', async () => { | ||
await page.goto(`${addr}/context.html`); | ||
const results = await new AxeBuilder({ page }) | ||
.exclude('.exclude') | ||
.exclude('.exclude2') | ||
.analyze(); | ||
const flattenTarget = flatPassesTargets(results); | ||
assert.notInclude(flattenTarget, '.exclude'); | ||
assert.notInclude(flattenTarget, '.exclude2'); | ||
}); | ||
it('with chaining includes and excludes', async () => { | ||
await page.goto(`${addr}/context.html`); | ||
const results = await new AxeBuilder({ page }) | ||
.include('.include') | ||
.include('.include2') | ||
.exclude('.exclude') | ||
.exclude('.exclude2') | ||
.analyze(); | ||
const flattenTarget = flatPassesTargets(results); | ||
assert.strictEqual(flattenTarget[0], '.include'); | ||
assert.strictEqual(flattenTarget[1], '.include2'); | ||
assert.notInclude(flattenTarget, '.exclude'); | ||
assert.notInclude(flattenTarget, '.exclude2'); | ||
}); | ||
it('with include using an array of strings', async () => { | ||
await page.goto(`${addr}/context.html`); | ||
const expected = ['.selector-one', '.selector-two', '.selector-three']; | ||
const axeSource = ` | ||
window.axe = { | ||
configure(){}, | ||
run({ include }){ | ||
return Promise.resolve({ include }) | ||
} | ||
} | ||
`; | ||
const results = new AxeBuilder({ page, axeSource: axeSource }).include([ | ||
'.selector-one', | ||
'.selector-two', | ||
'.selector-three' | ||
]); | ||
const { include: actual } = (await results.analyze()) as any; | ||
assert.deepEqual(actual[0], expected); | ||
}); | ||
it('with exclude using an array of strings', async () => { | ||
await page.goto(`${addr}/context.html`); | ||
const expected = ['.selector-one', '.selector-two', '.selector-three']; | ||
const axeSource = ` | ||
window.axe = { | ||
configure(){}, | ||
run({ exclude }){ | ||
return Promise.resolve({ exclude }) | ||
} | ||
} | ||
`; | ||
const results = new AxeBuilder({ page, axeSource: axeSource }).exclude([ | ||
'.selector-one', | ||
'.selector-two', | ||
'.selector-three' | ||
]); | ||
const { exclude: actual } = (await results.analyze()) as any; | ||
assert.deepEqual(actual[0], expected); | ||
}); | ||
}); | ||
@@ -443,3 +532,3 @@ | ||
assert.match( | ||
err.message, | ||
(err as Error).message, | ||
/Please make sure that you have popup blockers disabled./ | ||
@@ -460,3 +549,3 @@ ); | ||
} catch (err) { | ||
assert.match(err.message, /Please check out/); | ||
assert.match((err as Error).message, /Please check out/); | ||
} | ||
@@ -535,3 +624,3 @@ }); | ||
} catch (e) { | ||
error = e; | ||
error = e as Error; | ||
} | ||
@@ -538,0 +627,0 @@ assert.isNotNull(error); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102676
1758
177
2
1
Updatedaxe-core@^4.3.5
Updatedplaywright@^1.16.2