-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use test renderer during tests and when TERM=dumb
- Loading branch information
Showing
10 changed files
with
164 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict' | ||
|
||
const getRenderer = ({ debug, quiet }, env = process.env) => { | ||
if (quiet) return 'silent' | ||
// Better support for dumb terminals: https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals | ||
const isDumbTerminal = env.TERM === 'dumb' | ||
if (isDumbTerminal || env.NODE_ENV === 'test') return 'test' | ||
if (debug) return 'verbose' | ||
return 'update' | ||
} | ||
|
||
module.exports = getRenderer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import getRenderer from '../lib/getRenderer' | ||
|
||
describe('getRenderer', () => { | ||
it('should return silent when quiet', () => { | ||
expect(getRenderer({ quiet: true }, {})).toEqual('silent') | ||
}) | ||
|
||
it('should return test when NODE_ENV=test', () => { | ||
expect(getRenderer({}, { NODE_ENV: 'test' })).toEqual('test') | ||
}) | ||
|
||
it('should return test when TERM=dumb', () => { | ||
expect(getRenderer({}, { TERM: 'dumb' })).toEqual('test') | ||
}) | ||
|
||
it('should return verbose when debug', () => { | ||
expect(getRenderer({ debug: true }, {})).toEqual('verbose') | ||
}) | ||
|
||
it('should return update by default', () => { | ||
expect(getRenderer({}, {})).toEqual('update') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.