Skip to content

Commit

Permalink
test(printRestult): force color
Browse files Browse the repository at this point in the history
  • Loading branch information
10xLaCroixDrinker committed Mar 12, 2024
1 parent a219ced commit 8cbc3ac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/printResult.test.js
Expand Up @@ -179,6 +179,9 @@ test('should print with color when color is supported', (t) => {
}
}

const { FORCE_COLOR, NO_COLOR } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
const outputStream = new Writable({
write () {}
})
Expand All @@ -187,6 +190,10 @@ test('should print with color when color is supported', (t) => {
// act
const output = printResult(result, { outputStream })
t.ok(ansiRegex().test(output))

// cleanup
process.env.FORCE_COLOR = FORCE_COLOR
process.env.NO_COLOR = NO_COLOR
})

test('should not print with any color when color is not supported', (t) => {
Expand Down Expand Up @@ -226,11 +233,18 @@ test('should not print with any color when color is not supported', (t) => {
}
}

const { FORCE_COLOR, NO_COLOR } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
const outputStream = new Writable({
write () {}
})

// act
const output = printResult(result, { outputStream })
t.ok(!ansiRegex().test(output))

// cleanup
process.env.FORCE_COLOR = FORCE_COLOR
process.env.NO_COLOR = NO_COLOR
})

0 comments on commit 8cbc3ac

Please sign in to comment.