Skip to content

Commit

Permalink
test(examples): added skipping feat
Browse files Browse the repository at this point in the history
  • Loading branch information
mgordel committed Sep 21, 2023
1 parent c90975d commit 7495e54
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/docs-examples/examples/sending-data/worker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("Hello World");
9 changes: 9 additions & 0 deletions tests/examples/examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18

async function testAll(examples: Example[]) {
const failedTests = new Set<string>();
const skippedTests = new Set<string>();
if (!noGoth)
await Promise.race([
goth.start(),
Expand All @@ -70,6 +71,11 @@ async function testAll(examples: Example[]) {
for (const example of examples) {
try {
console.log(chalk.yellow(`\n---- Starting test: "${example.path}" ----\n`));
if (example?.skip) {
console.log(chalk.bgYellow.white(" SKIP "), chalk.yellow(`The test was skipped`));
skippedTests.add(example.path);
continue;
}
await test(example.cmd, example.path, example.args, example.timeout);
console.log(chalk.bgGreen.white(" PASS "), chalk.green(example.path));
} catch (error) {
Expand All @@ -82,10 +88,13 @@ async function testAll(examples: Example[]) {
chalk.bold.yellow("\n\nTESTS RESULTS: "),
chalk.bgGreen.black(` ${examples.length - failedTests.size} passed `),
chalk.bgRed.black(` ${failedTests.size} failed `),
skippedTests.size ? chalk.bgYellow.black(` ${skippedTests.size} skipped `) : "",
chalk.bgCyan.black(` ${examples.length} total `),
);
console.log(chalk.red("\nFailed tests:"));
failedTests.forEach((test) => console.log(chalk.red(`\t- ${test}`)));
console.log(chalk.yellow("\nSkipped tests:"));
failedTests.forEach((test) => console.log(chalk.yellow(`\t- ${test}`)));
process.exit(failedTests.size > 0 ? 1 : 0);
}

Expand Down

0 comments on commit 7495e54

Please sign in to comment.