Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken committed Dec 7, 2022
1 parent 554d3c0 commit ad1def0
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ const { TARGET_URL } = process.env;
module.exports = {
/** @param {import("nightwatch").NightwatchBrowser} client */
async ["Browser Test"](client) {
try {
const result = await new Promise((resolve) => {
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", resolve);
});
const result = await new Promise((resolve) => {
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", resolve);
});

// unexpected error
client.verify.ok(result.status === 0, "Check unexpected error");
if (result.status !== 0) {
throw result.value;
}
// unexpected error
client.verify.ok(result.status === 0, "Check unexpected error");
if (result.status !== 0) {
throw result.value;
}

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

// show error log
if (!success) {
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`);
}
// show error log
if (!success) {
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`);
}
} finally {
client.endSauce();
client.end();
}
},

afterEach(client) {
client.endSauce();
client.end();
},
};

0 comments on commit ad1def0

Please sign in to comment.