aria-ease 5.0.3 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -11
- package/{dist/src/utils/test/chunk-TUWQNVQJ.js → bin/chunk-7RMRFSJL.js} +51 -2
- package/bin/cli.cjs +135 -58
- package/bin/cli.js +1 -1
- package/bin/{contractTestRunnerPlaywright-O22AQ4RK.js → contractTestRunnerPlaywright-HL2VPEEV.js} +42 -24
- package/bin/{test-JNQFZBJA.js → test-HH2EW2NM.js} +44 -37
- package/dist/{chunk-KJ33RDSC.js → chunk-PDZQOXUN.js} +48 -2
- package/dist/{contractTestRunnerPlaywright-7ZOM7ZMG.js → contractTestRunnerPlaywright-EXEBWWPC.js} +42 -24
- package/dist/index.cjs +136 -58
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +44 -37
- package/{bin/chunk-TUWQNVQJ.js → dist/src/utils/test/chunk-7RMRFSJL.js} +45 -5
- package/dist/src/utils/test/{contractTestRunnerPlaywright-P5QZAIDR.js → contractTestRunnerPlaywright-LJHY3AB4.js} +40 -21
- package/dist/src/utils/test/contracts/ComboboxContract.json +2 -1
- package/dist/src/utils/test/contracts/MenuContract.json +2 -1
- package/dist/src/utils/test/index.cjs +130 -56
- package/dist/src/utils/test/index.d.cts +8 -3
- package/dist/src/utils/test/index.d.ts +8 -3
- package/dist/src/utils/test/index.js +43 -38
- package/package.json +4 -4
|
@@ -8,10 +8,15 @@ interface JestAxeResult {
|
|
|
8
8
|
* Runs static and interactions accessibility test on UI components.
|
|
9
9
|
* @param {string} componentName The name of the component contract to test against
|
|
10
10
|
* @param {HTMLElement} component The UI component to be tested
|
|
11
|
-
* @param {string} url Optional URL to run full Playwright E2E tests
|
|
11
|
+
* @param {string} url Optional URL to run full Playwright E2E tests. If omitted, uses isolated component testing with page.setContent()
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
declare function testUiComponent(componentName: string, component: HTMLElement, url
|
|
14
|
+
declare function testUiComponent(componentName: string, component: HTMLElement | null, url: string | null): Promise<JestAxeResult>;
|
|
15
15
|
declare let runTest: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Cleanup function to close the shared Playwright browser
|
|
18
|
+
* Call this in afterAll() or after all tests complete
|
|
19
|
+
*/
|
|
20
|
+
declare function cleanupTests(): Promise<void>;
|
|
16
21
|
|
|
17
|
-
export { runTest, testUiComponent };
|
|
22
|
+
export { cleanupTests, runTest, testUiComponent };
|
|
@@ -8,10 +8,15 @@ interface JestAxeResult {
|
|
|
8
8
|
* Runs static and interactions accessibility test on UI components.
|
|
9
9
|
* @param {string} componentName The name of the component contract to test against
|
|
10
10
|
* @param {HTMLElement} component The UI component to be tested
|
|
11
|
-
* @param {string} url Optional URL to run full Playwright E2E tests
|
|
11
|
+
* @param {string} url Optional URL to run full Playwright E2E tests. If omitted, uses isolated component testing with page.setContent()
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
declare function testUiComponent(componentName: string, component: HTMLElement, url
|
|
14
|
+
declare function testUiComponent(componentName: string, component: HTMLElement | null, url: string | null): Promise<JestAxeResult>;
|
|
15
15
|
declare let runTest: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Cleanup function to close the shared Playwright browser
|
|
18
|
+
* Call this in afterAll() or after all tests complete
|
|
19
|
+
*/
|
|
20
|
+
declare function cleanupTests(): Promise<void>;
|
|
16
21
|
|
|
17
|
-
export { runTest, testUiComponent };
|
|
22
|
+
export { cleanupTests, runTest, testUiComponent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractReporter, contract_default } from './chunk-
|
|
1
|
+
import { closeSharedBrowser, ContractReporter, contract_default } from './chunk-7RMRFSJL.js';
|
|
2
2
|
import { axe } from 'jest-axe';
|
|
3
3
|
import fs from 'fs/promises';
|
|
4
4
|
|
|
@@ -67,56 +67,58 @@ async function testUiComponent(componentName, component, url) {
|
|
|
67
67
|
if (!componentName || typeof componentName !== "string") {
|
|
68
68
|
throw new Error("\u274C testUiComponent requires a valid componentName (string)");
|
|
69
69
|
}
|
|
70
|
-
if (!component || !(component instanceof HTMLElement)) {
|
|
71
|
-
throw new Error("\u274C testUiComponent requires a valid component (HTMLElement)");
|
|
70
|
+
if (!url && (!component || !(component instanceof HTMLElement))) {
|
|
71
|
+
throw new Error("\u274C testUiComponent requires either a valid component (HTMLElement) or a URL");
|
|
72
72
|
}
|
|
73
73
|
if (url && typeof url !== "string") {
|
|
74
74
|
throw new Error("\u274C testUiComponent url parameter must be a string");
|
|
75
75
|
}
|
|
76
76
|
let results;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
if (component) {
|
|
78
|
+
try {
|
|
79
|
+
results = await axe(component);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`\u274C Axe accessibility scan failed
|
|
82
83
|
Error: ${error instanceof Error ? error.message : String(error)}`
|
|
83
|
-
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
results = { violations: [] };
|
|
84
88
|
}
|
|
85
|
-
async function checkDevServer(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const response = await fetch(serverUrl, {
|
|
95
|
-
method: "HEAD",
|
|
96
|
-
signal: AbortSignal.timeout(1e3)
|
|
97
|
-
});
|
|
98
|
-
if (response.ok || response.status === 304) {
|
|
99
|
-
return serverUrl;
|
|
100
|
-
}
|
|
101
|
-
} catch {
|
|
102
|
-
return null;
|
|
89
|
+
async function checkDevServer(url2) {
|
|
90
|
+
try {
|
|
91
|
+
const response = await fetch(url2, {
|
|
92
|
+
method: "HEAD",
|
|
93
|
+
signal: AbortSignal.timeout(1e3)
|
|
94
|
+
});
|
|
95
|
+
if (response.ok || response.status === 304) {
|
|
96
|
+
return url2;
|
|
103
97
|
}
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
104
100
|
}
|
|
105
101
|
return null;
|
|
106
102
|
}
|
|
107
103
|
let contract;
|
|
108
104
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
105
|
+
if (url) {
|
|
106
|
+
const devServerUrl = await checkDevServer(url);
|
|
107
|
+
if (devServerUrl) {
|
|
108
|
+
console.log(`\u{1F3AD} Running Playwright tests on ${devServerUrl}`);
|
|
109
|
+
const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-LJHY3AB4.js');
|
|
110
|
+
contract = await runContractTestsPlaywright(componentName, devServerUrl);
|
|
111
|
+
} else {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`\u274C Dev server not running at ${url}
|
|
114
|
+
Please start your dev server and try again.`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
} else if (component) {
|
|
118
|
+
console.log(`\u{1F3AD} Running component contract tests in JSDOM mode`);
|
|
119
119
|
contract = await runContractTests(componentName, component);
|
|
120
|
+
} else {
|
|
121
|
+
throw new Error("\u274C Either component or URL must be provided");
|
|
120
122
|
}
|
|
121
123
|
} catch (error) {
|
|
122
124
|
if (error instanceof Error) {
|
|
@@ -182,5 +184,8 @@ if (typeof window === "undefined") {
|
|
|
182
184
|
);
|
|
183
185
|
};
|
|
184
186
|
}
|
|
187
|
+
async function cleanupTests() {
|
|
188
|
+
await closeSharedBrowser();
|
|
189
|
+
}
|
|
185
190
|
|
|
186
|
-
export { runTest, testUiComponent };
|
|
191
|
+
export { cleanupTests, runTest, testUiComponent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aria-ease",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Out-of-the-box accessibility utility package to develop production ready applications.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -126,11 +126,11 @@
|
|
|
126
126
|
"dependencies": {
|
|
127
127
|
"chalk": "^5.6.2",
|
|
128
128
|
"commander": "^14.0.1",
|
|
129
|
-
"fs-extra": "^11.3.2"
|
|
130
|
-
"playwright": "^1.57.0"
|
|
129
|
+
"fs-extra": "^11.3.2"
|
|
131
130
|
},
|
|
132
131
|
"peerDependencies": {
|
|
133
|
-
"@axe-core/playwright": "^4.10.2"
|
|
132
|
+
"@axe-core/playwright": "^4.10.2",
|
|
133
|
+
"playwright": "^1.57.0"
|
|
134
134
|
},
|
|
135
135
|
"peerDependenciesMeta": {
|
|
136
136
|
"@axe-core/playwright": {
|