aria-ease 2.8.2 → 2.8.4
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/bin/audit-XABLAI36.js +47 -0
- package/{dist/chunk-PCORWVIQ.js → bin/chunk-JGKPHTSR.js} +0 -35
- package/bin/chunk-JSBRDJBE.js +30 -0
- package/bin/cli.cjs +13820 -0
- package/bin/cli.d.cts +1 -0
- package/bin/cli.d.ts +1 -0
- package/bin/cli.js +5 -243
- package/{dist/contractTestRunnerPlaywright-SE6TPWZZ.js → bin/contractTestRunnerPlaywright-EHQAMXQA.js} +7 -3
- package/bin/contractTestRunnerPlaywright-VDTXMVK5.js +263 -0
- package/bin/formatters-2RPHPXW2.js +176 -0
- package/bin/test-N6M7MDBZ.js +12804 -0
- package/bin/test-S2U633GD.js +12804 -0
- package/dist/{contractTestRunnerPlaywright-YNHMLHQ2.js → contractTestRunnerPlaywright-7O2T4JES.js} +5 -2
- package/dist/{contractTestRunnerPlaywright-ZY2T4UTV.js → contractTestRunnerPlaywright-AJ2DOOJT.js} +10 -2
- package/dist/index.cjs +10 -2
- package/dist/index.js +1 -1
- package/dist/src/utils/test/{contractTestRunnerPlaywright-I36Y2NHA.js → contractTestRunnerPlaywright-7O2T4JES.js} +5 -2
- package/dist/src/utils/test/{contractTestRunnerPlaywright-YNHMLHQ2.js → contractTestRunnerPlaywright-AJ2DOOJT.js} +10 -2
- package/dist/src/utils/test/index.cjs +10 -2
- package/dist/src/utils/test/index.js +1 -1
- package/package.json +2 -1
- package/dist/src/utils/test/contractTestRunnerPlaywright-ZY2T4UTV.js +0 -249
package/dist/{contractTestRunnerPlaywright-YNHMLHQ2.js → contractTestRunnerPlaywright-7O2T4JES.js}
RENAMED
|
@@ -25,8 +25,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
25
25
|
browser = await chromium.launch({ headless: true });
|
|
26
26
|
const context = await browser.newContext();
|
|
27
27
|
const page = await context.newPage();
|
|
28
|
-
await page.goto(url, {
|
|
29
|
-
|
|
28
|
+
await page.goto(url, {
|
|
29
|
+
waitUntil: "domcontentloaded",
|
|
30
|
+
timeout: 6e4
|
|
31
|
+
});
|
|
32
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
30
33
|
async function resolveRelativeTarget(selector, relative) {
|
|
31
34
|
const items = await page.locator(selector).all();
|
|
32
35
|
switch (relative) {
|
package/dist/{contractTestRunnerPlaywright-ZY2T4UTV.js → contractTestRunnerPlaywright-AJ2DOOJT.js}
RENAMED
|
@@ -25,8 +25,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
25
25
|
browser = await chromium.launch({ headless: true });
|
|
26
26
|
const context = await browser.newContext();
|
|
27
27
|
const page = await context.newPage();
|
|
28
|
-
await page.goto(url, {
|
|
29
|
-
|
|
28
|
+
await page.goto(url, {
|
|
29
|
+
waitUntil: "domcontentloaded",
|
|
30
|
+
timeout: 6e4
|
|
31
|
+
});
|
|
32
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
30
33
|
async function resolveRelativeTarget(selector, relative) {
|
|
31
34
|
const items = await page.locator(selector).all();
|
|
32
35
|
switch (relative) {
|
|
@@ -148,6 +151,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
148
151
|
continue;
|
|
149
152
|
}
|
|
150
153
|
const target = page.locator(keypressSelector).first();
|
|
154
|
+
const elementCount = await target.count();
|
|
155
|
+
if (elementCount === 0) {
|
|
156
|
+
reporter.reportTest(dynamicTest, "skip", `Skipping test - ${act.target} element not found (optional submenu test)`);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
151
159
|
await target.press(keyValue);
|
|
152
160
|
}
|
|
153
161
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -9419,8 +9419,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
9419
9419
|
browser = await import_playwright.chromium.launch({ headless: true });
|
|
9420
9420
|
const context = await browser.newContext();
|
|
9421
9421
|
const page = await context.newPage();
|
|
9422
|
-
await page.goto(url, {
|
|
9423
|
-
|
|
9422
|
+
await page.goto(url, {
|
|
9423
|
+
waitUntil: "domcontentloaded",
|
|
9424
|
+
timeout: 6e4
|
|
9425
|
+
});
|
|
9426
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
9424
9427
|
async function resolveRelativeTarget(selector, relative) {
|
|
9425
9428
|
const items = await page.locator(selector).all();
|
|
9426
9429
|
switch (relative) {
|
|
@@ -9542,6 +9545,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
9542
9545
|
continue;
|
|
9543
9546
|
}
|
|
9544
9547
|
const target = page.locator(keypressSelector).first();
|
|
9548
|
+
const elementCount = await target.count();
|
|
9549
|
+
if (elementCount === 0) {
|
|
9550
|
+
reporter.reportTest(dynamicTest, "skip", `Skipping test - ${act.target} element not found (optional submenu test)`);
|
|
9551
|
+
break;
|
|
9552
|
+
}
|
|
9545
9553
|
await target.press(keyValue);
|
|
9546
9554
|
}
|
|
9547
9555
|
}
|
package/dist/index.js
CHANGED
|
@@ -13171,7 +13171,7 @@ async function testUiComponent(componentName, component, url) {
|
|
|
13171
13171
|
let contract;
|
|
13172
13172
|
if (url) {
|
|
13173
13173
|
console.log(`\u{1F3AD} Running Playwright E2E tests on ${url}`);
|
|
13174
|
-
const { runContractTestsPlaywright } = await import("./contractTestRunnerPlaywright-
|
|
13174
|
+
const { runContractTestsPlaywright } = await import("./contractTestRunnerPlaywright-AJ2DOOJT.js");
|
|
13175
13175
|
contract = await runContractTestsPlaywright(componentName, url);
|
|
13176
13176
|
} else {
|
|
13177
13177
|
console.log(`\u{1F9EA} Running jsdom tests (limited event handling)`);
|
|
@@ -21,8 +21,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
21
21
|
browser = await chromium.launch({ headless: true });
|
|
22
22
|
const context = await browser.newContext();
|
|
23
23
|
const page = await context.newPage();
|
|
24
|
-
await page.goto(url, {
|
|
25
|
-
|
|
24
|
+
await page.goto(url, {
|
|
25
|
+
waitUntil: "domcontentloaded",
|
|
26
|
+
timeout: 6e4
|
|
27
|
+
});
|
|
28
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
26
29
|
async function resolveRelativeTarget(selector, relative) {
|
|
27
30
|
const items = await page.locator(selector).all();
|
|
28
31
|
switch (relative) {
|
|
@@ -21,8 +21,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
21
21
|
browser = await chromium.launch({ headless: true });
|
|
22
22
|
const context = await browser.newContext();
|
|
23
23
|
const page = await context.newPage();
|
|
24
|
-
await page.goto(url, {
|
|
25
|
-
|
|
24
|
+
await page.goto(url, {
|
|
25
|
+
waitUntil: "domcontentloaded",
|
|
26
|
+
timeout: 6e4
|
|
27
|
+
});
|
|
28
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
26
29
|
async function resolveRelativeTarget(selector, relative) {
|
|
27
30
|
const items = await page.locator(selector).all();
|
|
28
31
|
switch (relative) {
|
|
@@ -144,6 +147,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
144
147
|
continue;
|
|
145
148
|
}
|
|
146
149
|
const target = page.locator(keypressSelector).first();
|
|
150
|
+
const elementCount = await target.count();
|
|
151
|
+
if (elementCount === 0) {
|
|
152
|
+
reporter.reportTest(dynamicTest, "skip", `Skipping test - ${act.target} element not found (optional submenu test)`);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
147
155
|
await target.press(keyValue);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
@@ -9257,8 +9257,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
9257
9257
|
browser = await playwright.chromium.launch({ headless: true });
|
|
9258
9258
|
const context = await browser.newContext();
|
|
9259
9259
|
const page = await context.newPage();
|
|
9260
|
-
await page.goto(url, {
|
|
9261
|
-
|
|
9260
|
+
await page.goto(url, {
|
|
9261
|
+
waitUntil: "domcontentloaded",
|
|
9262
|
+
timeout: 6e4
|
|
9263
|
+
});
|
|
9264
|
+
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 6e4 });
|
|
9262
9265
|
async function resolveRelativeTarget(selector, relative) {
|
|
9263
9266
|
const items = await page.locator(selector).all();
|
|
9264
9267
|
switch (relative) {
|
|
@@ -9380,6 +9383,11 @@ async function runContractTestsPlaywright(componentName, url) {
|
|
|
9380
9383
|
continue;
|
|
9381
9384
|
}
|
|
9382
9385
|
const target = page.locator(keypressSelector).first();
|
|
9386
|
+
const elementCount = await target.count();
|
|
9387
|
+
if (elementCount === 0) {
|
|
9388
|
+
reporter.reportTest(dynamicTest, "skip", `Skipping test - ${act.target} element not found (optional submenu test)`);
|
|
9389
|
+
break;
|
|
9390
|
+
}
|
|
9383
9391
|
await target.press(keyValue);
|
|
9384
9392
|
}
|
|
9385
9393
|
}
|
|
@@ -12524,7 +12524,7 @@ async function testUiComponent(componentName, component, url) {
|
|
|
12524
12524
|
let contract;
|
|
12525
12525
|
if (url) {
|
|
12526
12526
|
console.log(`\u{1F3AD} Running Playwright E2E tests on ${url}`);
|
|
12527
|
-
const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-
|
|
12527
|
+
const { runContractTestsPlaywright } = await import('./contractTestRunnerPlaywright-AJ2DOOJT.js');
|
|
12528
12528
|
contract = await runContractTestsPlaywright(componentName, url);
|
|
12529
12529
|
} else {
|
|
12530
12530
|
console.log(`\u{1F9EA} Running jsdom tests (limited event handling)`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aria-ease",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.4",
|
|
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",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
},
|
|
108
108
|
"files": [
|
|
109
109
|
"dist",
|
|
110
|
+
"bin",
|
|
110
111
|
"README.md",
|
|
111
112
|
"LICENSE"
|
|
112
113
|
],
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { ContractReporter, contract_default } from './chunk-SSBW5VAA.js';
|
|
2
|
-
import { chromium } from 'playwright';
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
async function runContractTestsPlaywright(componentName, url) {
|
|
6
|
-
const reporter = new ContractReporter(true);
|
|
7
|
-
const contractTyped = contract_default;
|
|
8
|
-
const contractPath = contractTyped[componentName]?.path;
|
|
9
|
-
if (!contractPath) {
|
|
10
|
-
throw new Error(`Contract path not found for component: ${componentName}`);
|
|
11
|
-
}
|
|
12
|
-
const resolvedPath = new URL(contractPath, import.meta.url).pathname;
|
|
13
|
-
const contractData = readFileSync(resolvedPath, "utf-8");
|
|
14
|
-
const componentContract = JSON.parse(contractData);
|
|
15
|
-
const totalTests = componentContract.static[0].assertions.length + componentContract.dynamic.length;
|
|
16
|
-
reporter.start(componentName, totalTests);
|
|
17
|
-
const failures = [];
|
|
18
|
-
const passes = [];
|
|
19
|
-
let browser = null;
|
|
20
|
-
try {
|
|
21
|
-
browser = await chromium.launch({ headless: true });
|
|
22
|
-
const context = await browser.newContext();
|
|
23
|
-
const page = await context.newPage();
|
|
24
|
-
await page.goto(url, { waitUntil: "networkidle" });
|
|
25
|
-
await page.waitForSelector(componentContract.selectors.trigger, { timeout: 9e4 });
|
|
26
|
-
async function resolveRelativeTarget(selector, relative) {
|
|
27
|
-
const items = await page.locator(selector).all();
|
|
28
|
-
switch (relative) {
|
|
29
|
-
case "first":
|
|
30
|
-
return items[0];
|
|
31
|
-
case "second":
|
|
32
|
-
return items[1];
|
|
33
|
-
case "last":
|
|
34
|
-
return items[items.length - 1];
|
|
35
|
-
case "next": {
|
|
36
|
-
const currentIndex = await page.evaluate(([sel]) => {
|
|
37
|
-
const items2 = Array.from(document.querySelectorAll(sel));
|
|
38
|
-
return items2.indexOf(document.activeElement);
|
|
39
|
-
}, [selector]);
|
|
40
|
-
const nextIndex = (currentIndex + 1) % items.length;
|
|
41
|
-
return items[nextIndex];
|
|
42
|
-
}
|
|
43
|
-
case "previous": {
|
|
44
|
-
const currentIndex = await page.evaluate(([sel]) => {
|
|
45
|
-
const items2 = Array.from(document.querySelectorAll(sel));
|
|
46
|
-
return items2.indexOf(document.activeElement);
|
|
47
|
-
}, [selector]);
|
|
48
|
-
const prevIndex = (currentIndex - 1 + items.length) % items.length;
|
|
49
|
-
return items[prevIndex];
|
|
50
|
-
}
|
|
51
|
-
default:
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
for (const test of componentContract.static[0]?.assertions || []) {
|
|
56
|
-
if (test.target === "relative") continue;
|
|
57
|
-
const targetSelector = componentContract.selectors[test.target];
|
|
58
|
-
if (!targetSelector) {
|
|
59
|
-
failures.push(`Selector for target ${test.target} not found.`);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const target = page.locator(targetSelector).first();
|
|
63
|
-
const exists = await target.count() > 0;
|
|
64
|
-
if (!exists) {
|
|
65
|
-
failures.push(`Target ${test.target} not found.`);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (!test.expectedValue) {
|
|
69
|
-
const attributes = test.attribute.split(" | ");
|
|
70
|
-
let hasAny = false;
|
|
71
|
-
for (const attr of attributes) {
|
|
72
|
-
const value = await target.getAttribute(attr.trim());
|
|
73
|
-
if (value !== null) {
|
|
74
|
-
hasAny = true;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (!hasAny) {
|
|
79
|
-
failures.push(test.failureMessage + ` None of the attributes "${test.attribute}" are present.`);
|
|
80
|
-
} else {
|
|
81
|
-
passes.push(`At least one of the attributes "${test.attribute}" exists on the element.`);
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
const attributeValue = await target.getAttribute(test.attribute);
|
|
85
|
-
const expectedValues = test.expectedValue.split(" | ");
|
|
86
|
-
if (!attributeValue || !expectedValues.includes(attributeValue)) {
|
|
87
|
-
failures.push(test.failureMessage + ` Attribute value does not match expected value. Expected: ${test.expectedValue}, Found: ${attributeValue}`);
|
|
88
|
-
} else {
|
|
89
|
-
passes.push(`Attribute value matches expected value. Expected: ${test.expectedValue}, Found: ${attributeValue}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
for (const dynamicTest of componentContract.dynamic || []) {
|
|
94
|
-
const { action, assertions } = dynamicTest;
|
|
95
|
-
const failuresBeforeTest = failures.length;
|
|
96
|
-
const containerElement = page.locator(componentContract.selectors.container).first();
|
|
97
|
-
const triggerElement = page.locator(componentContract.selectors.trigger).first();
|
|
98
|
-
const isContainerVisible = await containerElement.isVisible();
|
|
99
|
-
if (isContainerVisible) {
|
|
100
|
-
await triggerElement.click();
|
|
101
|
-
await page.waitForTimeout(50);
|
|
102
|
-
}
|
|
103
|
-
for (const act of action) {
|
|
104
|
-
if (act.type === "click") {
|
|
105
|
-
if (act.target === "document") {
|
|
106
|
-
await page.mouse.click(10, 10);
|
|
107
|
-
} else {
|
|
108
|
-
const actionSelector = componentContract.selectors[act.target];
|
|
109
|
-
if (!actionSelector) {
|
|
110
|
-
failures.push(`Selector for action target ${act.target} not found.`);
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
await page.locator(actionSelector).first().click();
|
|
114
|
-
await page.waitForTimeout(200);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (act.type === "keypress" && act.key) {
|
|
118
|
-
const keyMap = {
|
|
119
|
-
"Space": "Space",
|
|
120
|
-
"Enter": "Enter",
|
|
121
|
-
"Escape": "Escape",
|
|
122
|
-
"Arrow Up": "ArrowUp",
|
|
123
|
-
"Arrow Down": "ArrowDown",
|
|
124
|
-
"Arrow Left": "ArrowLeft",
|
|
125
|
-
"Arrow Right": "ArrowRight",
|
|
126
|
-
"Home": "Home",
|
|
127
|
-
"End": "End",
|
|
128
|
-
"Tab": "Tab"
|
|
129
|
-
};
|
|
130
|
-
let keyValue = keyMap[act.key] || act.key;
|
|
131
|
-
if (keyValue === "Space") {
|
|
132
|
-
keyValue = " ";
|
|
133
|
-
} else if (keyValue.includes(" ")) {
|
|
134
|
-
keyValue = keyValue.replace(/ /g, "");
|
|
135
|
-
}
|
|
136
|
-
if (act.target === "focusable" && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Escape"].includes(keyValue)) {
|
|
137
|
-
await page.waitForTimeout(100);
|
|
138
|
-
await page.keyboard.press(keyValue);
|
|
139
|
-
await page.waitForTimeout(50);
|
|
140
|
-
} else {
|
|
141
|
-
const keypressSelector = componentContract.selectors[act.target];
|
|
142
|
-
if (!keypressSelector) {
|
|
143
|
-
failures.push(`Selector for keypress target ${act.target} not found.`);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
const target = page.locator(keypressSelector).first();
|
|
147
|
-
await target.press(keyValue);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
await page.waitForTimeout(100);
|
|
151
|
-
}
|
|
152
|
-
for (const assertion of assertions) {
|
|
153
|
-
let target;
|
|
154
|
-
if (assertion.target === "relative") {
|
|
155
|
-
const relativeSelector = componentContract.selectors.relative;
|
|
156
|
-
if (!relativeSelector) {
|
|
157
|
-
failures.push("Relative selector is not defined in the contract.");
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
if (!assertion.expectedValue) {
|
|
161
|
-
failures.push("Expected value for relative target is not defined.");
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
target = await resolveRelativeTarget(relativeSelector, assertion.expectedValue);
|
|
165
|
-
} else {
|
|
166
|
-
const assertionSelector = componentContract.selectors[assertion.target];
|
|
167
|
-
if (!assertionSelector) {
|
|
168
|
-
failures.push(`Selector for assertion target ${assertion.target} not found.`);
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
target = page.locator(assertionSelector).first();
|
|
172
|
-
}
|
|
173
|
-
if (!target) {
|
|
174
|
-
failures.push(`Target ${assertion.target} not found.`);
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (assertion.assertion === "toBeVisible") {
|
|
178
|
-
const isVisible = await target.isVisible();
|
|
179
|
-
if (isVisible) {
|
|
180
|
-
passes.push(`${assertion.target} is visible as expected. Test: "${dynamicTest.description}".`);
|
|
181
|
-
} else {
|
|
182
|
-
failures.push(`${assertion.failureMessage}`);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (assertion.assertion === "notToBeVisible") {
|
|
186
|
-
const isVisible = await target.isVisible();
|
|
187
|
-
if (!isVisible) {
|
|
188
|
-
passes.push(`${assertion.target} is not visible as expected. Test: "${dynamicTest.description}".`);
|
|
189
|
-
} else {
|
|
190
|
-
failures.push(assertion.failureMessage + ` ${assertion.target} is still visible.`);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (assertion.assertion === "toHaveAttribute" && assertion.attribute && assertion.expectedValue) {
|
|
194
|
-
const attributeValue = await target.getAttribute(assertion.attribute);
|
|
195
|
-
if (attributeValue === assertion.expectedValue) {
|
|
196
|
-
passes.push(`${assertion.target} has expected "${assertion.attribute}". Test: "${dynamicTest.description}".`);
|
|
197
|
-
} else {
|
|
198
|
-
failures.push(assertion.failureMessage + ` ${assertion.target} "${assertion.attribute}" should be "${assertion.expectedValue}", found "${attributeValue}".`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (assertion.assertion === "toHaveFocus") {
|
|
202
|
-
const hasFocus = await target.evaluate((el) => el === document.activeElement);
|
|
203
|
-
if (hasFocus) {
|
|
204
|
-
passes.push(`${assertion.target} has focus as expected. Test: "${dynamicTest.description}".`);
|
|
205
|
-
} else {
|
|
206
|
-
failures.push(`${assertion.failureMessage}`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (assertion.assertion === "toHaveRole" && assertion.expectedValue) {
|
|
210
|
-
const roleValue = await target.getAttribute("role");
|
|
211
|
-
if (roleValue === assertion.expectedValue) {
|
|
212
|
-
passes.push(`${assertion.target} has role "${assertion.expectedValue}". Test: "${dynamicTest.description}".`);
|
|
213
|
-
} else {
|
|
214
|
-
failures.push(assertion.failureMessage + ` Expected role "${assertion.expectedValue}", found "${roleValue}".`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const failuresAfterTest = failures.length;
|
|
219
|
-
const testPassed = failuresAfterTest === failuresBeforeTest;
|
|
220
|
-
const failureMessage = testPassed ? void 0 : failures[failures.length - 1];
|
|
221
|
-
reporter.reportTest(dynamicTest, testPassed ? "pass" : "fail", failureMessage);
|
|
222
|
-
}
|
|
223
|
-
const staticPassed = componentContract.static[0].assertions.length;
|
|
224
|
-
const staticFailed = 0;
|
|
225
|
-
reporter.reportStatic(staticPassed, staticFailed);
|
|
226
|
-
reporter.summary(failures);
|
|
227
|
-
} catch (error) {
|
|
228
|
-
if (error instanceof Error) {
|
|
229
|
-
if (error.message.includes("Executable doesn't exist")) {
|
|
230
|
-
console.error("\n\u274C Playwright browsers not found!\n");
|
|
231
|
-
console.log("\u{1F4E6} Run: npx playwright install chromium\n");
|
|
232
|
-
failures.push("Playwright browser not installed. Run: npx playwright install chromium");
|
|
233
|
-
} else if (error.message.includes("net::ERR_CONNECTION_REFUSED")) {
|
|
234
|
-
console.error("\n\u274C Cannot connect to dev server!\n");
|
|
235
|
-
console.log(` Make sure your dev server is running at ${url}
|
|
236
|
-
`);
|
|
237
|
-
failures.push(`Dev server not running at ${url}`);
|
|
238
|
-
} else {
|
|
239
|
-
console.error("\u274C Playwright test error:", error.message);
|
|
240
|
-
failures.push(`Test error: ${error.message}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} finally {
|
|
244
|
-
if (browser) await browser.close();
|
|
245
|
-
}
|
|
246
|
-
return { passes, failures };
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export { runContractTestsPlaywright };
|