From 8cbc3acf1d586eb5c02fab31a0ee07930154d3bb Mon Sep 17 00:00:00 2001 From: Jamie King Date: Tue, 12 Mar 2024 04:10:55 -0700 Subject: [PATCH] test(printRestult): force color --- test/printResult.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/printResult.test.js b/test/printResult.test.js index 90c9c148..7e17128a 100644 --- a/test/printResult.test.js +++ b/test/printResult.test.js @@ -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 () {} }) @@ -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) => { @@ -226,6 +233,9 @@ 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 () {} }) @@ -233,4 +243,8 @@ test('should not print with any color when color is not 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 })