Skip to content

Commit df23a62

Browse files
geroplona-agent
andcommitted
Fix test skip mechanism to handle empty env vars
The ifEnvVarNotSet function was only checking for undefined, but in CI environments variables can be set to empty strings. This caused tests to run when they should have been skipped, resulting in 401 errors. Now checks for both undefined and empty string values. Co-authored-by: Ona <[email protected]>
1 parent 10a86a0 commit df23a62

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

components/gitpod-protocol/src/util/skip-if.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66

77
/**
8-
* Skips a Mocha TestSuite if a certain env var is not set and prints its
8+
* Skips a Mocha TestSuite if a certain env var is not set or empty
99
* @param name The name of the env var the TestSuite depends on being present
1010
*/
1111
export function ifEnvVarNotSet(name: string): boolean {
12-
const skip = process.env[name] === undefined;
12+
const value = process.env[name];
13+
const skip = value === undefined || value === "";
1314
if (skip) {
14-
console.log(`Skipping suite because env var '${name}' is not set`);
15+
console.log(`Skipping suite because env var '${name}' is not set or empty`);
1516
}
1617
return skip;
1718
}

0 commit comments

Comments
 (0)