-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish option #1424
Merged
Merged
Publish option #1424
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
9f1c3d1
Added scenario for --publish option
b3a2880
Add --publish option
6ca7dc7
Make publish scenario pass with cheating
7cbe75d
Add a ReportServer to the World
56c0888
Start TDDing HttpStream
1095cf1
Write HttpStream in a temporary file
cbliard 8cdfbca
Pipe tempfile to http request
5171e70
Wait for request to finish before closing server
1a00e04
Capture body on server
227eea9
Wait for the server to receive all the body
cbliard 632eb6a
Add new test for GET/PUT redirect between lambda and S3
f2fe72d
Follow Location after get
dd0ebcc
Fix dependency lint
10f8184
Cleanup
981a98f
Refactor
9211f0b
Extract HttpStream
fc17393
Extract FakeReportServer
b465540
Use FakeReportServer in publish.feature
e3f922c
Add failing spec for --publish
dae139e
Scenario is passing
c13b8ce
Print response body in errors. Send content-length
8891803
Added tests for outputting a banner from the report server content
vincent-psarga f1bdd5e
Merge master. Update Hook signature to allow async functions
cddacff
http_stream logs response from server to console
vincent-psarga 28ff61b
Enable publishing report with ENV var
vincent-psarga 599c4ae
Fix lint error
80fb637
Start adding support for CUCUMBER_PUBLISH_TOKEN
903ff39
Publish with Authorization header when CUCUMBER_PUBLISH_TOKEN is set
vincent-psarga 1b898df
Restore newline
6276818
Add scenarios describing the banner advertising --publish
vincent-psarga d7a926f
Start implementing banner display when --publish is not set
vincent-psarga 19ade46
Add isPublishing attribute to configuration
vincent-psarga 231a2d8
Add test checking is suppressPublicationBanner is set + added --publi…
vincent-psarga be84b19
Merge remote-tracking branch 'origin/master' into publish-option
4a51358
Print banners to stderr, fixed import of cucumber
2388754
Adapt banner to cucumber.js
cbliard 5097c2a
Add ANSI colours to banner
ed63063
Extract banner code to its own file
vincent-psarga 0048be2
more maintainable publish banner
charlierudolph 841d8d6
revert dep lint config, lint fix banner
charlierudolph 508c876
Use arrow function
9629395
Use doesHaveValue in conditionals. Update comment about 3xx redirects
860f430
Use valueOrDefault instead of boolean expression
vincent-psarga 272c7bb
Merge branch 'master' into publish-option
vincent-psarga 2bdd55e
Update changelog
vincent-psarga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,131 @@ | ||
Feature: Publish reports | ||
|
||
Background: | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: a feature | ||
Scenario: a scenario | ||
Given a step | ||
""" | ||
And a file named "features/step_definitions/steps.js" with: | ||
""" | ||
const {Given} = require('@cucumber/cucumber') | ||
|
||
Given(/^a step$/, function() {}) | ||
""" | ||
|
||
@spawn | ||
Scenario: Report is published when --publish is specified | ||
Given a report server is running on 'http://localhost:9987' | ||
When I run cucumber-js with arguments `--publish` and env `CUCUMBER_PUBLISH_URL=http://localhost:9987/api/reports` | ||
Then it passes | ||
And the server should receive the following message types: | ||
| meta | | ||
| source | | ||
| gherkinDocument | | ||
| pickle | | ||
| stepDefinition | | ||
| testRunStarted | | ||
| testCase | | ||
| testCaseStarted | | ||
| testStepStarted | | ||
| testStepFinished | | ||
| testCaseFinished | | ||
| testRunFinished | | ||
|
||
@spawn | ||
Scenario: Report is published when CUCUMBER_PUBLISH_ENABLED is set | ||
Given a report server is running on 'http://localhost:9987' | ||
When I run cucumber-js with arguments `` and env `CUCUMBER_PUBLISH_ENABLED=1 CUCUMBER_PUBLISH_URL=http://localhost:9987/api/reports` | ||
Then it passes | ||
And the server should receive the following message types: | ||
| meta | | ||
| source | | ||
| gherkinDocument | | ||
| pickle | | ||
| stepDefinition | | ||
| testRunStarted | | ||
| testCase | | ||
| testCaseStarted | | ||
| testStepStarted | | ||
| testStepFinished | | ||
| testCaseFinished | | ||
| testRunFinished | | ||
|
||
@spawn | ||
Scenario: Report is published when CUCUMBER_PUBLISH_TOKEN is set | ||
Given a report server is running on 'http://localhost:9987' | ||
When I run cucumber-js with arguments `` and env `CUCUMBER_PUBLISH_TOKEN=keyboardcat CUCUMBER_PUBLISH_URL=http://localhost:9987/api/reports` | ||
Then it passes | ||
And the server should receive the following message types: | ||
| meta | | ||
| source | | ||
| gherkinDocument | | ||
| pickle | | ||
| stepDefinition | | ||
| testRunStarted | | ||
| testCase | | ||
| testCaseStarted | | ||
| testStepStarted | | ||
| testStepFinished | | ||
| testCaseFinished | | ||
| testRunFinished | | ||
And the server should receive an "Authorization" header with value "Bearer keyboardcat" | ||
|
||
@spawn | ||
Scenario: a banner is displayed after publication | ||
Given a report server is running on 'http://localhost:9987' | ||
When I run cucumber-js with arguments `--publish` and env `CUCUMBER_PUBLISH_URL=http://localhost:9987/api/reports` | ||
Then the error output contains the text: | ||
""" | ||
┌──────────────────────────────────────────────────────────────────────────┐ | ||
│ View your Cucumber Report at: │ | ||
│ https://reports.cucumber.io/reports/f318d9ec-5a3d-4727-adec-bd7b69e2edd3 │ | ||
│ │ | ||
│ This report will self-destruct in 24h unless it is claimed or deleted. │ | ||
└──────────────────────────────────────────────────────────────────────────┘ | ||
""" | ||
|
||
@spawn | ||
Scenario: when results are not published, a banner explains how to publish | ||
When I run cucumber-js | ||
Then the error output contains the text: | ||
""" | ||
┌──────────────────────────────────────────────────────────────────────────┐ | ||
│ Share your Cucumber Report with your team at https://reports.cucumber.io │ | ||
│ │ | ||
│ Command line option: --publish │ | ||
│ Environment variable: CUCUMBER_PUBLISH_ENABLED=true │ | ||
│ │ | ||
│ More information at https://reports.cucumber.io/docs/cucumber-js │ | ||
│ │ | ||
│ To disable this message, add this to your ./cucumber.js: │ | ||
│ module.exports = { default: '--publish-quiet' } │ | ||
└──────────────────────────────────────────────────────────────────────────┘ | ||
""" | ||
@spawn | ||
Scenario: the publication banner is not shown when publication is done | ||
When I run cucumber-js with arguments `<args>` and env `<env>` | ||
Then the error output does not contain the text: | ||
""" | ||
Share your Cucumber Report with your team at https://reports.cucumber.io | ||
""" | ||
|
||
Examples: | ||
| args | env | | ||
| --publish | | | ||
| | CUCUMBER_PUBLISH_ENABLED=true | | ||
| | CUCUMBER_PUBLISH_TOKEN=123456 | | ||
|
||
@spawn | ||
Scenario: the publication banner is not shown when publication is disabled | ||
When I run cucumber-js with arguments `<args>` and env `<env>` | ||
Then the error output does not contain the text: | ||
""" | ||
Share your Cucumber Report with your team at https://reports.cucumber.io | ||
""" | ||
|
||
Examples: | ||
| args | env | | ||
| --publish-quiet | | | ||
| | CUCUMBER_PUBLISH_QUIET=true | |
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,42 @@ | ||
import { Given, Then, DataTable } from '../..' | ||
import { World } from '../support/world' | ||
import { expect } from 'chai' | ||
import { URL } from 'url' | ||
import FakeReportServer from '../../test/fake_report_server' | ||
import assert from 'assert' | ||
|
||
Given('a report server is running on {string}', async function ( | ||
this: World, | ||
url: string | ||
) { | ||
const port = parseInt(new URL(url).port) | ||
this.reportServer = new FakeReportServer(port) | ||
await this.reportServer.start() | ||
}) | ||
|
||
Then('the server should receive the following message types:', async function ( | ||
this: World, | ||
expectedMessageTypesTable: DataTable | ||
) { | ||
const expectedMessageTypes = expectedMessageTypesTable | ||
.raw() | ||
.map((row) => row[0]) | ||
|
||
const receivedBodies = await this.reportServer.stop() | ||
const ndjson = receivedBodies.toString('utf-8').trim() | ||
if (ndjson === '') assert.fail('Server received nothing') | ||
|
||
const receivedMessageTypes = ndjson | ||
.split(/\n/) | ||
.map((line) => JSON.parse(line)) | ||
.map((envelope) => Object.keys(envelope)[0]) | ||
|
||
expect(receivedMessageTypes).to.deep.eq(expectedMessageTypes) | ||
}) | ||
|
||
Then( | ||
'the server should receive a(n) {string} header with value {string}', | ||
function (this: World, name: string, value: string) { | ||
expect(this.reportServer.receivedHeaders[name.toLowerCase()]).to.eq(value) | ||
} | ||
) |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel conflicted about this. This feels annoying to me as a user. Certainly glad we implemented the CLI option to suppress it but why does this need to be outputted a user runs the tool without publish?
Could this be a message shown on install / the help page / somewhere visible on the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've already implemented it this way in Cucumber-Ruby and Cucumber-JVM. So far we've not heard any complaints, just positive feedback.
We want as many people as possible to discover this new functionality, and showing it after the run will reach more people than if it's only shown on install and in documentation (which many people never look at).
Let's see if anyone complains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me. I'll complain. I'm beginning the setup of a test suite and this message is annoying to look at. I tried dropping the module.exports into my step definition file but it didn't get rid of this message. So how do I get rid of this?
And to be clear, I appreciate the thought - but I'm working on a corporate project which will NEVER publish test results onto a public server for security reasons, so I'd rather just have this reminder off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're not supposed to drop that in your step definition files, but in your global
cucumber.js
config file at the root of your project.How can we make this harder to misunderstand @michaelm-rsi?
I completely understand that, which is why we've added an option to turn this off. We're also considering making Cucumber Reports available as a server you can install on-prem.