-
-
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.
* Added scenario for --publish option * Add --publish option * Make publish scenario pass with cheating * Add a ReportServer to the World * Start TDDing HttpStream * Write HttpStream in a temporary file * Pipe tempfile to http request * Wait for request to finish before closing server * Capture body on server * Wait for the server to receive all the body * Add new test for GET/PUT redirect between lambda and S3 * Follow Location after get * Fix dependency lint * Cleanup * Refactor * Extract HttpStream * Extract FakeReportServer * Use FakeReportServer in publish.feature * Add failing spec for --publish * Scenario is passing * Print response body in errors. Send content-length * Added tests for outputting a banner from the report server content * http_stream logs response from server to console * Enable publishing report with ENV var * Fix lint error * Start adding support for CUCUMBER_PUBLISH_TOKEN * Publish with Authorization header when CUCUMBER_PUBLISH_TOKEN is set * Restore newline * Add scenarios describing the banner advertising --publish * Start implementing banner display when --publish is not set * Add isPublishing attribute to configuration * Add test checking is suppressPublicationBanner is set + added --publish-quiet option * Print banners to stderr, fixed import of cucumber * Adapt banner to cucumber.js * Add ANSI colours to banner * Extract banner code to its own file * more maintainable publish banner * revert dep lint config, lint fix banner * Use arrow function * Use doesHaveValue in conditionals. Update comment about 3xx redirects * Use valueOrDefault instead of boolean expression * Update changelog Co-authored-by: Seb Rose <[email protected]> Co-authored-by: Christophe Bliard <[email protected]> Co-authored-by: Vincent Pretre <[email protected]> Co-authored-by: Charles Rudolph <[email protected]>
- Loading branch information
1 parent
c7e8c35
commit fede5c8
Showing
20 changed files
with
986 additions
and
22 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
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.