Skip to content

Commit

Permalink
run format
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdesignory committed Nov 5, 2024
1 parent c93d246 commit b3d82bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
62 changes: 31 additions & 31 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,42 @@
<script src="benchmark-runner-tests.mjs" type="module"></script>
<script type="module">
function startTest() {
const runner = mocha.run()
window.mochaResults = runner;
const runner = mocha.run();
window.mochaResults = runner;

function createReport(node) {
const tree = {
tests: [],
suites: [],
id: node.id,
title: node.title,
root: node.root,
};
function createReport(node) {
const tree = {
tests: [],
suites: [],
id: node.id,
title: node.title,
root: node.root,
};

for (const test of node.tests) {
tree.tests.push({
id: test.id,
title: test.title,
state: test.state,
error: {
name: test?.err?.name,
message: test?.err?.message
}
});
}
for (const test of node.tests) {
tree.tests.push({
id: test.id,
title: test.title,
state: test.state,
error: {
name: test?.err?.name,
message: test?.err?.message,
},
});
}

for (const suite of node.suites) {
tree.suites.push(createReport(suite));
}
for (const suite of node.suites) {
tree.suites.push(createReport(suite));
}

return tree;
}
return tree;
}

runner.on("end", function () {
window.suite = createReport(runner.suite);
const event = new Event("test-complete");
window.dispatchEvent(event);
});
runner.on("end", function () {
window.suite = createReport(runner.suite);
const event = new Event("test-complete");
window.dispatchEvent(event);
});
}
window.addEventListener("start-test", startTest);
</script>
Expand Down
8 changes: 3 additions & 5 deletions tests/run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import serve from "./server.mjs";
import { Builder, Capabilities } from "selenium-webdriver";
import commandLineArgs from "command-line-args";
import commandLineUsage from "command-line-usage";
import assert from "assert";

const optionDefinitions = [
{ name: "browser", type: String, description: "Set the browser to test, choices are [safari, firefox, chrome]. By default the $BROWSER env variable is used." },
Expand Down Expand Up @@ -76,9 +75,9 @@ function printTree(node) {
for (const test of node.tests) {
console.group();
if (test.state === "passed") {
console.log("\x1b[32m✓", `\x1b[30m${ test.title}`);
console.log("\x1b[32m✓", `\x1b[30m${test.title}`);
} else {
console.log("\x1b[31m✖", `\x1b[30m${ test.title}`);
console.log("\x1b[31m✖", `\x1b[30m${test.title}`);
console.group();
console.log(`\x1b[31m${test.error.name}: ${test.error.message}`);
console.groupEnd();
Expand Down Expand Up @@ -113,11 +112,10 @@ async function test() {
});

printTree(result.suite);
if (result.stats.failures > 0){
if (result.stats.failures > 0) {
console.error("\n\x1b[31m✖ Not all tests passed!\n");
process.exit(1);
}

} finally {
console.log("\n\x1b[32m✓ All tests passed!\n");
driver.quit();
Expand Down

0 comments on commit b3d82bd

Please sign in to comment.