Skip to content

Commit 1bba058

Browse files
committed
add programmatic skip example
1 parent 912136c commit 1bba058

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test } from "node:test";
2+
import assert from "node:assert/strict";
3+
4+
test(
5+
"skips using config if environment variable is missing",
6+
{ skip: !process.env.REQUIRED_ENV_VARIABLE },
7+
() => {
8+
assert.fail("if we get here, we need REQUIRED_ENV_VARIABLE and fail");
9+
},
10+
);
11+
12+
test("skips programmatically if environment variable is missing", (t) => {
13+
if (!process.env.REQUIRED_ENV_VARIABLE) {
14+
return t.skip("REQUIRED_ENV_VARIABLE is missing");
15+
}
16+
17+
assert.fail(
18+
'If we got here the ".failing" modifier would not be satisfied since the test passed',
19+
);
20+
});

0 commit comments

Comments
 (0)