Skip to content

Commit

Permalink
Merge branch 'main' into update-migration-links-to-jsonschemas
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelien-reeves committed Jun 4, 2021
2 parents abfff77 + c00274b commit 2785248
Show file tree
Hide file tree
Showing 26 changed files with 288 additions and 282 deletions.
3 changes: 1 addition & 2 deletions features/fixtures/formatters/passed-rule.message.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module.exports = [
{
source: {
uri: 'features/a.feature',
data:
'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
data: 'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
mediaType: 'text/x.cucumber.gherkin+plain',
},
},
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@
"@types/stream-buffers": "3.0.3",
"@types/tmp": "0.2.0",
"@types/verror": "1.10.4",
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"@typescript-eslint/eslint-plugin": "4.26.0",
"@typescript-eslint/parser": "4.26.0",
"chai": "4.3.4",
"chai-exclude": "2.0.3",
"coffeescript": "2.5.1",
"dependency-lint": "6.0.0",
"dirty-chai": "2.0.1",
"eslint": "7.25.0",
"eslint": "7.27.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard-with-typescript": "20.0.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-promise": "5.1.0",
Expand All @@ -246,7 +246,7 @@
"mocha": "8.4.0",
"mustache": "4.2.0",
"nyc": "15.1.0",
"prettier": "2.2.1",
"prettier": "2.3.0",
"semver": "7.3.5",
"sinon": "11.1.1",
"sinon-chai": "3.7.0",
Expand Down
49 changes: 14 additions & 35 deletions src/cli/configuration_builder_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -99,11 +96,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -124,11 +118,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -151,11 +142,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -175,11 +163,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand All @@ -199,11 +184,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand All @@ -223,11 +205,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand Down
4 changes: 3 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export default class Cli {
supportCodeLibrary,
}
if (doesNotHaveValue(formatOptions.colorsEnabled)) {
typeOptions.parsedArgvOptions.colorsEnabled = (stream as TtyWriteStream).isTTY
typeOptions.parsedArgvOptions.colorsEnabled = (
stream as TtyWriteStream
).isTTY
}
if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {
const outputToName = outputTo === '' ? 'stdout' : outputTo
Expand Down
10 changes: 4 additions & 6 deletions src/formatter/helpers/event_data_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ export default class EventDataCollector {
testStepId,
testStepResult,
}: messages.TestStepFinished): void {
this.testCaseAttemptDataMap[testCaseStartedId].stepResults[
testStepId
] = testStepResult
this.testCaseAttemptDataMap[testCaseStartedId].stepResults[testStepId] =
testStepResult
}

storeTestCaseResult({ testCaseStartedId }: messages.TestCaseFinished): void {
const stepResults = values(
this.testCaseAttemptDataMap[testCaseStartedId].stepResults
)
this.testCaseAttemptDataMap[
testCaseStartedId
].worstTestStepResult = messages.getWorstTestStepResult(stepResults)
this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult =
messages.getWorstTestStepResult(stepResults)
}
}
5 changes: 2 additions & 3 deletions src/formatter/helpers/gherkin_document_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ export function getGherkinScenarioLocationMap(
gherkinDocument: messages.GherkinDocument
): Record<string, messages.Location> {
const locationMap: Record<string, messages.Location> = {}
const scenarioMap: Record<string, messages.Scenario> = getGherkinScenarioMap(
gherkinDocument
)
const scenarioMap: Record<string, messages.Scenario> =
getGherkinScenarioMap(gherkinDocument)
_.entries<messages.Scenario>(scenarioMap).forEach(([id, scenario]) => {
locationMap[id] = scenario.location
if (doesHaveValue(scenario.examples)) {
Expand Down
12 changes: 8 additions & 4 deletions src/formatter/helpers/gherkin_document_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = getGherkinStepMap(gherkinDocument)
Expand Down Expand Up @@ -156,7 +157,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = getGherkinScenarioMap(gherkinDocument)
Expand Down Expand Up @@ -215,7 +217,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = await getGherkinExampleRuleMap(gherkinDocument)
Expand Down Expand Up @@ -284,7 +287,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = await getGherkinScenarioLocationMap(gherkinDocument)
Expand Down
5 changes: 2 additions & 3 deletions src/formatter/helpers/pickle_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function getPickleLocation({
gherkinDocument,
pickle,
}: IGetPickleLocationRequest): messages.Location {
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
return gherkinScenarioLocationMap[_.last(pickle.astNodeIds)]
}
5 changes: 2 additions & 3 deletions src/formatter/helpers/test_case_attempt_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ export function parseTestCaseAttempt({
}: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt {
const { testCase, pickle, gherkinDocument } = testCaseAttempt
const gherkinStepMap = getGherkinStepMap(gherkinDocument)
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
const pickleStepMap = getPickleStepMap(pickle)
const relativePickleUri = pickle.uri
const parsedTestCase: IParsedTestCase = {
Expand Down
10 changes: 4 additions & 6 deletions src/formatter/helpers/usage_helpers/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ describe('Usage Helpers', () => {
const supportCodeLibrary = buildSupportCodeLibrary(({ Given }) => {
Given('a step', code)
})
const {
eventDataCollector,
} = await getEnvelopesAndEventDataCollector({ supportCodeLibrary })
const { eventDataCollector } =
await getEnvelopesAndEventDataCollector({ supportCodeLibrary })

// Act
const output = getUsage({
Expand Down Expand Up @@ -53,9 +52,8 @@ describe('Usage Helpers', () => {
)
}
)
const {
eventDataCollector,
} = await getEnvelopesAndEventDataCollector({ supportCodeLibrary })
const { eventDataCollector } =
await getEnvelopesAndEventDataCollector({ supportCodeLibrary })

// Act
const output = getUsage({
Expand Down
12 changes: 4 additions & 8 deletions src/formatter/json_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import { parseStepArgument } from '../step_arguments'

const { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser

const {
getScenarioDescription,
getPickleStepMap,
getStepKeyword,
} = PickleParser
const { getScenarioDescription, getPickleStepMap, getStepKeyword } =
PickleParser

export interface IJsonFeature {
description: string
Expand Down Expand Up @@ -148,9 +145,8 @@ export default class JsonFormatter extends Formatter {
const gherkinStepMap = getGherkinStepMap(gherkinDocument)
const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)
const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {
const { pickle } = testCaseAttempt
const pickleStepMap = getPickleStepMap(pickle)
Expand Down
8 changes: 4 additions & 4 deletions src/formatter/json_formatter_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ describe('JsonFormatter', () => {
})

// Assert
const stepArguments = JSON.parse(output)[0].elements[0].steps[0]
.arguments
const stepArguments =
JSON.parse(output)[0].elements[0].steps[0].arguments
expect(stepArguments).to.eql([
{
content: 'This is a DocString',
Expand Down Expand Up @@ -359,8 +359,8 @@ describe('JsonFormatter', () => {
})

// Assert
const stepArguments = JSON.parse(output)[0].elements[0].steps[0]
.arguments
const stepArguments =
JSON.parse(output)[0].elements[0].steps[0].arguments
expect(stepArguments).to.eql([
{
rows: [
Expand Down
5 changes: 2 additions & 3 deletions src/formatter/progress_bar_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export default class ProgressBarFormatter extends Formatter {
testStepId,
testCaseStartedId,
}: messages.TestStepFinished): void {
const { testCase } = this.eventDataCollector.getTestCaseAttempt(
testCaseStartedId
)
const { testCase } =
this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)
const testStep = testCase.testSteps.find((s) => s.id === testStepId)
if (doesHaveValue(testStep.pickleStepId)) {
this.progressBar.tick()
Expand Down
15 changes: 6 additions & 9 deletions src/formatter/progress_bar_formatter_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand All @@ -125,8 +124,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nRule: b\nExample: c\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nRule: b\nExample: c\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand All @@ -149,8 +147,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand Down Expand Up @@ -370,8 +367,7 @@ describe('ProgressBarFormatter', () => {
// Arrange
const sources = [
{
data:
'Feature: a\nScenario: b\nGiven a passing step\n When a flaky step\nThen a passing step',
data: 'Feature: a\nScenario: b\nGiven a passing step\n When a flaky step\nThen a passing step',
uri: 'a.feature',
},
]
Expand All @@ -384,7 +380,8 @@ describe('ProgressBarFormatter', () => {
sources,
supportCodeLibrary,
})
const progressBar = progressBarFormatter.progressBar as sinon.SinonStubbedInstance<ProgressBar>
const progressBar =
progressBarFormatter.progressBar as sinon.SinonStubbedInstance<ProgressBar>

// Assert
expect(progressBar.interrupt).to.have.callCount(1)
Expand Down
Loading

0 comments on commit 2785248

Please sign in to comment.