Skip to content

Commit

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

const { FORCE_COLOR, NO_COLOR, COLOR, CI } = process.env
const { FORCE_COLOR, NO_COLOR, COLOR, CI, COLORTERM } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
delete process.env.COLOR
delete process.env.CI
process.env.COLORTERM = 'truecolor'
const outputStream = new Writable({
write () {}
})
Expand All @@ -198,6 +199,7 @@ test('should print with color when color is supported', (t) => {
process.env.NO_COLOR = NO_COLOR
process.env.COLOR = COLOR
process.env.CI = CI
process.env.COLORTERM = COLORTERM
})

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

const { FORCE_COLOR, NO_COLOR, COLOR, CI } = process.env
const { FORCE_COLOR, NO_COLOR, COLOR, CI, COLORTERM } = process.env
delete process.env.FORCE_COLOR
delete process.env.NO_COLOR
delete process.env.COLOR
delete process.env.CI
process.env.COLORTERM = 'truecolor'
const outputStream = new Writable({
write () {}
})
Expand All @@ -255,4 +258,5 @@ test('should not print with any color when color is not supported', (t) => {
process.env.NO_COLOR = NO_COLOR
process.env.COLOR = COLOR
process.env.CI = CI
process.env.COLORTERM = COLORTERM
})

0 comments on commit 9be343a

Please sign in to comment.