Skip to content

Commit bcab9c8

Browse files
committed
add GINKGO_NO_COLOR to disable colors via environment variables
1 parent 7e65a00 commit bcab9c8

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3445,7 +3445,7 @@ When you [filter specs](#filtering-specs) using Ginkgo's various filtering mecha
34453445
#### Other Settings
34463446
Here are a grab bag of other settings:
34473447

3448-
You can disable Ginkgo's color output by running `ginkgo --no-color`.
3448+
You can disable Ginkgo's color output by running `ginkgo --no-color` or setting the `GINKGO_NO_COLOR=TRUE` environment variable.
34493449
You can also output in a format that makes it easier to read in github actions console by running `ginkgo --github-output`.
34503450

34513451
By default, Ginkgo only emits full stack traces when a spec panics. When a normal assertion failure occurs, Ginkgo simply emits the line at which the failure occurred. You can, instead, have Ginkgo always emit the full stack trace by running `ginkgo --trace`.

formatter/formatter.go

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ func New(colorMode ColorMode) Formatter {
8282
return fmt.Sprintf("\x1b[38;5;%dm", colorCode)
8383
}
8484

85+
if _, noColor := os.LookupEnv("GINKGO_NO_COLOR"); noColor {
86+
colorMode = ColorModeNone
87+
}
88+
8589
f := Formatter{
8690
ColorMode: colorMode,
8791
colors: map[string]string{

types/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ var ParallelConfigFlags = GinkgoFlags{
328328
// ReporterConfigFlags provides flags for the Ginkgo test process, and CLI
329329
var ReporterConfigFlags = GinkgoFlags{
330330
{KeyPath: "R.NoColor", Name: "no-color", SectionKey: "output", DeprecatedName: "noColor", DeprecatedDocLink: "changed-command-line-flags",
331-
Usage: "If set, suppress color output in default reporter."},
331+
Usage: "If set, suppress color output in default reporter. You can also set the environment variable GINKGO_NO_COLOR=TRUE"},
332332
{KeyPath: "R.Verbose", Name: "v", SectionKey: "output",
333333
Usage: "If set, emits more output including GinkgoWriter contents."},
334334
{KeyPath: "R.VeryVerbose", Name: "vv", SectionKey: "output",

0 commit comments

Comments
 (0)