Skip to content

Commit dbf9c15

Browse files
committed
Fix
1 parent 9ea804f commit dbf9c15

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

test/browser/index.js

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,29 @@ const { TARGET_URL } = process.env;
1010
/** @type {import("nightwatch").NightwatchTestFunctions} */
1111
module.exports = {
1212
/** @param {import("nightwatch").NightwatchBrowser} client */
13-
async ["Browser Test"](client) {
14-
let response = null;
15-
let success = false;
16-
17-
try {
18-
response = await client.url(
19-
TARGET_URL || "http://127.0.0.1:8000/power.html",
20-
)
21-
.waitForElementPresent("#mocha-report .suite:nth-of-type(4)", 30000)
22-
.findElements("#mocha-report .test .error");
23-
} catch (e) {
24-
if (e.name === "NoSuchElementError") {
25-
success = true;
26-
} else {
27-
// unexpected error
28-
throw e;
13+
["Browser Test"](client) {
14+
client.url(TARGET_URL || "http://127.0.0.1:8000/power.html")
15+
.waitForElementPresent("#mocha-report .suite:nth-of-type(4)", 30000)
16+
.elements("css selector", "#mocha-report .test .error", async (result) => {
17+
// unexpected error
18+
client.verify.ok(result.status === 0, "Check unexpected error");
19+
if (result.status === 0) {
20+
console.error();
21+
return;
2922
}
30-
}
3123

32-
client.verify.ok(success, "Check error elements");
33-
if (success) {
34-
return;
35-
}
24+
const success = result.value == null || result.value.length === 0;
25+
client.verify.ok(success, "Check error elements");
26+
if (success) {
27+
return;
28+
}
3629

37-
// show error log
38-
for (const element of response.value) {
39-
const id = element.getId();
40-
const { value: error } = await client.elementIdText(id);
41-
client.verify.ok(false, `\n\n${red}${error}${reset}\n\n`);
42-
}
30+
// show error log
31+
for (const element of result.value) {
32+
const { value: error } = await client.elementIdText(element.ELEMENT);
33+
client.verify.ok(false, `\n\n${red}${error}${reset}\n\n`);
34+
}
35+
});
4336
},
4437

4538
afterEach(client, done) {

0 commit comments

Comments
 (0)