-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to enable debug logging (#2120)
* add new environment flag * basic plumbing for debug logging * add some real logging for config * simplify interface, add more logging, support testing * add doco * add more logging around configuration * simplify type
- Loading branch information
1 parent
7298f30
commit 1213a71
Showing
27 changed files
with
259 additions
and
43 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
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,9 @@ | ||
# Debugging | ||
|
||
If things aren't working the way you expect with Cucumber, you can enable debug logging. When this is enabled, Cucumber will emit logging to `stderr` relating to configuration and other things that can help you pin down a problem with your project. | ||
|
||
Cucumber uses the [popular `debug` library](https://www.npmjs.com/package/debug) to detect when debug logging should be enabled, under the `cucumber` scope. To enable debug logging, set the `DEBUG` environment variable, like: | ||
|
||
```shell | ||
DEBUG=cucumber | ||
``` |
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,37 @@ | ||
@spawn | ||
Feature: debug | ||
|
||
As a Cucumber user | ||
I want to enable debug logging | ||
So that I can troubleshoot issues with my project | ||
|
||
Background: | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: some feature | ||
Scenario: | ||
Given a step passes | ||
When a step passes | ||
Then a step passes | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
const {Given} = require('@cucumber/cucumber') | ||
Given(/^a step passes$/, function() {}); | ||
""" | ||
|
||
Scenario: | ||
Given my env includes "DEBUG=cucumber" | ||
When I run cucumber-js | ||
Then the error output contains the text: | ||
""" | ||
No configuration file found | ||
""" | ||
|
||
Scenario: | ||
When I run cucumber-js | ||
Then the error output does not contain the text: | ||
""" | ||
No configuration file found | ||
""" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
import { Console } from 'console' | ||
import { Writable } from 'stream' | ||
import { ILogger } from '../logger' | ||
|
||
export class ConsoleLogger implements ILogger { | ||
private console: Console = new Console(this.stream) | ||
constructor(private stream: Writable, private debugEnabled: boolean) {} | ||
|
||
debug(...content: any[]): void { | ||
if (this.debugEnabled) { | ||
this.console.debug(...content) | ||
} | ||
} | ||
|
||
error(...content: any[]): void { | ||
this.console.error(...content) | ||
} | ||
|
||
warn(...content: any[]): void { | ||
this.console.warn(...content) | ||
} | ||
} |
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
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.