Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Feb 11, 2022
1 parent 9ea804f commit dbf9c15
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,29 @@ const { TARGET_URL } = process.env;
/** @type {import("nightwatch").NightwatchTestFunctions} */
module.exports = {
/** @param {import("nightwatch").NightwatchBrowser} client */
async ["Browser Test"](client) {
let response = null;
let success = false;

try {
response = await client.url(
TARGET_URL || "http://127.0.0.1:8000/power.html",
)
.waitForElementPresent("#mocha-report .suite:nth-of-type(4)", 30000)
.findElements("#mocha-report .test .error");
} catch (e) {
if (e.name === "NoSuchElementError") {
success = true;
} else {
// unexpected error
throw e;
["Browser Test"](client) {
client.url(TARGET_URL || "http://127.0.0.1:8000/power.html")
.waitForElementPresent("#mocha-report .suite:nth-of-type(4)", 30000)
.elements("css selector", "#mocha-report .test .error", async (result) => {
// unexpected error
client.verify.ok(result.status === 0, "Check unexpected error");
if (result.status === 0) {
console.error();
return;
}
}

client.verify.ok(success, "Check error elements");
if (success) {
return;
}
const success = result.value == null || result.value.length === 0;
client.verify.ok(success, "Check error elements");
if (success) {
return;
}

// show error log
for (const element of response.value) {
const id = element.getId();
const { value: error } = await client.elementIdText(id);
client.verify.ok(false, `\n\n${red}${error}${reset}\n\n`);
}
// show error log
for (const element of result.value) {
const { value: error } = await client.elementIdText(element.ELEMENT);
client.verify.ok(false, `\n\n${red}${error}${reset}\n\n`);
}
});
},

afterEach(client, done) {
Expand Down

0 comments on commit dbf9c15

Please sign in to comment.