Skip to content

Commit 88f0560

Browse files
authored
Fix logging test (#4077)
* Fix logging test * Add comment to explain * Make test run conditionally * Merge remote-tracking branch 'origin/master' into fix-logging-test
1 parent 3bb0617 commit 88f0560

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/client/test/logging.spec.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ describe('[Logging]', () => {
3333
}
3434
})
3535

36-
// This test breaks for no obvious reason and we don't run it in CI anyway.
37-
// Running the client confirms that logging is using correct color schemes.
38-
it.skip('should colorize key=value pairs', () => {
36+
// must be run with `FORCE_COLOR='1' npx vitest test/logging.spec.ts`
37+
it.skipIf(process.env.FORCE_COLOR !== '1')('should colorize key=value pairs', () => {
3938
if (process.env.GITHUB_ACTION !== undefined) {
4039
assert.isTrue(true, 'no color functionality in ci')
4140
return
@@ -44,9 +43,15 @@ describe('[Logging]', () => {
4443
level: 'info',
4544
message: 'test key=value',
4645
}) as any
47-
assert.strictEqual(
48-
message,
49-
'test \x1B[38;2;0;128;0mkey\x1B[39m=value ', // cspell:disable-line
46+
47+
// matches either ESC[32m (basic green) or ESC[38;2;0;128;0m (true-color green)
48+
function hasGreen(str: string): boolean {
49+
// eslint-disable-next-line
50+
return /\x1B\[(?:32|38;2;0;128;0)m/.test(str)
51+
}
52+
53+
assert.isTrue(
54+
hasGreen(message), // cspell:disable-line
5055
'key=value pairs should be colorized',
5156
)
5257
})

0 commit comments

Comments
 (0)