Skip to content

Commit

Permalink
Merge branch 'main' into unstable-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed Jun 22, 2023
2 parents 5dcc6ee + 8fece83 commit d6db66d
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 84 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber
## [Unreleased]
### Added
- New option for JUnit test suite name to be passed in `formatOptions` ([#2265](https://github.com/cucumber/cucumber-js/issues/2265))
- Logging and calculation is decoupled in `logFailedTestCases()` for easier customization ([#2290](https://github.com/cucumber/cucumber-js/issues/2290))

### Changed
- separator of `RerunFormatter` is changed to protected from private ([#2290](https://github.com/cucumber/cucumber-js/issues/2290))
- Include source reference in emitted messages for parameter types ([#2287](https://github.com/cucumber/cucumber-js/pull/2287))

### Fixed
- Correctly interpret retried scenarios in rerun formatter ([#2290](https://github.com/cucumber/cucumber-js/issues/2290))
- Correctly interpret retried scenarios in rerun formatter ([#2292](https://github.com/cucumber/cucumber-js/pull/2292))

## [9.1.2] - 2023-05-07
### Changed
Expand Down
57 changes: 31 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@
"node": "14 || 16 || 18 || 19"
},
"dependencies": {
"@cucumber/ci-environment": "9.1.0",
"@cucumber/cucumber-expressions": "16.1.1",
"@cucumber/gherkin": "26.0.3",
"@cucumber/ci-environment": "9.2.0",
"@cucumber/cucumber-expressions": "16.1.2",
"@cucumber/gherkin": "26.2.0",
"@cucumber/gherkin-streams": "5.0.1",
"@cucumber/gherkin-utils": "8.0.2",
"@cucumber/html-formatter": "20.2.1",
"@cucumber/html-formatter": "20.3.0",
"@cucumber/message-streams": "4.0.1",
"@cucumber/messages": "21.0.1",
"@cucumber/messages": "22.0.0",
"@cucumber/tag-expressions": "5.0.1",
"assertion-error-formatter": "^3.0.0",
"capital-case": "^1.0.4",
Expand Down Expand Up @@ -249,7 +249,7 @@
"yup": "^0.32.11"
},
"devDependencies": {
"@cucumber/compatibility-kit": "11.2.0",
"@cucumber/compatibility-kit": "11.3.0",
"@cucumber/query": "12.0.1",
"@microsoft/api-documenter": "7.19.27",
"@microsoft/api-extractor": "7.33.7",
Expand Down
35 changes: 15 additions & 20 deletions src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
import { PickleOrder } from '../models/pickle_order'
import { builtinParameterTypes } from '../support_code_library_builder'
import { version } from '../version'
import { ILogger } from '../logger'
import { ILineAndUri } from '../types'

interface IParseGherkinMessageStreamRequest {
cwd?: string
Expand Down Expand Up @@ -119,23 +119,33 @@ export async function emitMetaMessage(
})
}

const makeSourceReference = (source: ILineAndUri) => ({
uri: source.uri,
location: {
line: source.line,
},
})

function emitParameterTypes(
supportCodeLibrary: ISupportCodeLibrary,
eventBroadcaster: EventEmitter,
newId: IdGenerator.NewId
): void {
for (const parameterType of supportCodeLibrary.parameterTypeRegistry
.parameterTypes) {
if (builtinParameterTypes.includes(parameterType.name)) {
if (parameterType.builtin) {
continue
}
const source =
supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType)
const envelope: messages.Envelope = {
parameterType: {
id: newId(),
name: parameterType.name,
preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,
regularExpressions: parameterType.regexpStrings,
useForSnippets: parameterType.useForSnippets,
sourceReference: makeSourceReference(source),
},
}
eventBroadcaster.emit('envelope', envelope)
Expand Down Expand Up @@ -169,12 +179,7 @@ function emitStepDefinitions(
? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION
: messages.StepDefinitionPatternType.REGULAR_EXPRESSION,
},
sourceReference: {
uri: stepDefinition.uri,
location: {
line: stepDefinition.line,
},
},
sourceReference: makeSourceReference(stepDefinition),
},
}
eventBroadcaster.emit('envelope', envelope)
Expand All @@ -196,12 +201,7 @@ function emitTestCaseHooks(
id: testCaseHookDefinition.id,
name: testCaseHookDefinition.name,
tagExpression: testCaseHookDefinition.tagExpression,
sourceReference: {
uri: testCaseHookDefinition.uri,
location: {
line: testCaseHookDefinition.line,
},
},
sourceReference: makeSourceReference(testCaseHookDefinition),
},
}
eventBroadcaster.emit('envelope', envelope)
Expand All @@ -221,12 +221,7 @@ function emitTestRunHooks(
const envelope: messages.Envelope = {
hook: {
id: testRunHookDefinition.id,
sourceReference: {
uri: testRunHookDefinition.uri,
location: {
line: testRunHookDefinition.line,
},
},
sourceReference: makeSourceReference(testRunHookDefinition),
},
}
eventBroadcaster.emit('envelope', envelope)
Expand Down
24 changes: 17 additions & 7 deletions src/cli/helpers_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import StepDefinition from '../models/step_definition'
import {
CucumberExpression,
ParameterType,
ParameterTypeRegistry,
RegularExpression,
} from '@cucumber/cucumber-expressions'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
import { PickleOrder } from '../models/pickle_order'
import { SourcedParameterTypeRegistry } from '../support_code_library_builder/sourced_parameter_type_registry'

const noopFunction = (): void => {
// no code
Expand Down Expand Up @@ -79,7 +79,7 @@ function testEmitSupportCodeMessages(
afterTestCaseHookDefinitions: [],
afterTestStepHookDefinitions: [],
defaultTimeout: 0,
parameterTypeRegistry: new ParameterTypeRegistry(),
parameterTypeRegistry: new SourcedParameterTypeRegistry(),
undefinedParameterTypes: [],
World: null,
parallelCanAssign: () => true,
Expand All @@ -105,16 +105,20 @@ describe('helpers', () => {
})
describe('emitSupportCodeMessages', () => {
it('emits messages for parameter types', () => {
const parameterTypeRegistry = new ParameterTypeRegistry()
parameterTypeRegistry.defineParameterType(
const parameterTypeRegistry = new SourcedParameterTypeRegistry()
parameterTypeRegistry.defineSourcedParameterType(
new ParameterType<string>(
'flight',
['([A-Z]{3})-([A-Z]{3})'],
null,
() => 'argh',
true,
false
)
),
{
line: 4,
uri: 'features/support/parameter-types.js',
}
)

const envelopes = testEmitSupportCodeMessages({
Expand All @@ -129,6 +133,12 @@ describe('helpers', () => {
preferForRegularExpressionMatch: false,
regularExpressions: ['([A-Z]{3})-([A-Z]{3})'],
useForSnippets: true,
sourceReference: {
uri: 'features/support/parameter-types.js',
location: {
line: 4,
},
},
},
},
]
Expand All @@ -149,7 +159,7 @@ describe('helpers', () => {
pattern: 'I have {int} cukes in my belly',
expression: new CucumberExpression(
'I have {int} cukes in my belly',
new ParameterTypeRegistry()
new SourcedParameterTypeRegistry()
),
}),
],
Expand Down Expand Up @@ -188,7 +198,7 @@ describe('helpers', () => {
pattern: /I have (\d+) cukes in my belly/,
expression: new RegularExpression(
/I have (\d+) cukes in my belly/,
new ParameterTypeRegistry()
new SourcedParameterTypeRegistry()
),
}),
],
Expand Down
23 changes: 5 additions & 18 deletions src/support_code_library_builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import arity from 'util-arity'

import {
CucumberExpression,
ParameterTypeRegistry,
RegularExpression,
} from '@cucumber/cucumber-expressions'
import { doesHaveValue, doesNotHaveValue } from '../value_checker'
Expand All @@ -34,6 +33,7 @@ import {
import World from './world'
import { ICanonicalSupportCodeIds } from '../runtime/parallel/command_types'
import { GherkinStepKeyword } from '../models/gherkin_step_keyword'
import { SourcedParameterTypeRegistry } from './sourced_parameter_type_registry'

interface IStepDefinitionConfig {
code: any
Expand Down Expand Up @@ -65,20 +65,6 @@ interface ITestRunHookDefinitionConfig {
uri: string
}

export const builtinParameterTypes = [
'bigdecimal',
'biginteger',
'byte',
'double',
'float',
'int',
'long',
'short',
'string',
'word',
'',
]

export class SupportCodeLibraryBuilder {
public readonly methods: IDefineSupportCodeMethods

Expand All @@ -93,7 +79,7 @@ export class SupportCodeLibraryBuilder {
private defaultTimeout: number
private definitionFunctionWrapper: any
private newId: IdGenerator.NewId
private parameterTypeRegistry: ParameterTypeRegistry
private parameterTypeRegistry: SourcedParameterTypeRegistry
private stepDefinitionConfigs: IStepDefinitionConfig[]
private World: any
private parallelCanAssign: ParallelAssignmentValidator
Expand Down Expand Up @@ -166,7 +152,8 @@ export class SupportCodeLibraryBuilder {

defineParameterType(options: IParameterTypeDefinition<any>): void {
const parameterType = buildParameterType(options)
this.parameterTypeRegistry.defineParameterType(parameterType)
const source = getDefinitionLineAndUri(this.cwd)
this.parameterTypeRegistry.defineSourcedParameterType(parameterType, source)
}

defineStep(
Expand Down Expand Up @@ -481,7 +468,7 @@ export class SupportCodeLibraryBuilder {
this.beforeTestStepHookDefinitionConfigs = []
this.definitionFunctionWrapper = null
this.defaultTimeout = 5000
this.parameterTypeRegistry = new ParameterTypeRegistry()
this.parameterTypeRegistry = new SourcedParameterTypeRegistry()
this.stepDefinitionConfigs = []
this.parallelCanAssign = () => true
this.World = World
Expand Down
Loading

0 comments on commit d6db66d

Please sign in to comment.