Skip to content

Commit

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

const { FORCE_COLOR, NO_COLOR, COLOR, CI } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
delete process.env.COLOR
delete process.env.CI
const outputStream = new Writable({
write () {}
})
Expand All @@ -187,6 +192,12 @@ 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
process.env.COLOR = COLOR
process.env.CI = CI
})

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

const { FORCE_COLOR, NO_COLOR, COLOR, CI } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
delete process.env.COLOR
delete process.env.CI
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
process.env.COLOR = COLOR
process.env.CI = CI
})

0 comments on commit 095ba9a

Please sign in to comment.