Skip to content

Update CCK test to work with new structure #2602

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

Merged
merged 4 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions compatibility/cck_spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs'
import path from 'node:path'
import { PassThrough, pipeline, Writable } from 'node:stream'
import util from 'node:util'
import { PassThrough, Writable } from 'node:stream'
import { pipeline } from 'node:stream/promises'
import { describe, it } from 'mocha'
import { config, expect, use } from 'chai'
import chaiExclude from 'chai-exclude'
Expand All @@ -12,7 +12,6 @@ import { Envelope } from '@cucumber/messages'
import { ignorableKeys } from '../features/support/formatter_output_helpers'
import { runCucumber, IRunConfiguration } from '../src/api'

const asyncPipeline = util.promisify(pipeline)
const PROJECT_PATH = path.join(__dirname, '..')
const CCK_FEATURES_PATH = 'node_modules/@cucumber/compatibility-kit/features'
const CCK_IMPLEMENTATIONS_PATH = 'compatibility/features'
Expand All @@ -21,35 +20,36 @@ config.truncateThreshold = 100
use(chaiExclude)

describe('Cucumber Compatibility Kit', () => {
const ndjsonFiles = glob.sync(`${CCK_FEATURES_PATH}/**/*.ndjson`)
ndjsonFiles.forEach((fixturePath) => {
const match = /^.+[/\\](.+)(\.feature(?:\.md)?)\.ndjson$/.exec(fixturePath)
const suiteName = match[1]
const extension = match[2]
it(`passes the cck suite for '${suiteName}'`, async () => {
const directories = glob.sync(`${CCK_FEATURES_PATH}/*`, { nodir: false })

for (const directory of directories) {
const suite = path.basename(directory)

it(suite, async () => {
const actualMessages: Envelope[] = []
const stdout = new PassThrough()
const stderr = new PassThrough()
const runConfiguration: IRunConfiguration = {
sources: {
defaultDialect: 'en',
paths: [`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`],
paths: [
`${CCK_FEATURES_PATH}/${suite}/*.feature`,
`${CCK_FEATURES_PATH}/${suite}/*.feature.md`,
],
names: [],
tagExpression: '',
order: 'defined',
},
support: {
requireModules: ['ts-node/register'],
requirePaths: [
`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`,
],
requirePaths: [`${CCK_IMPLEMENTATIONS_PATH}/${suite}/*.ts`],
},
runtime: {
dryRun: false,
failFast: false,
filterStacktraces: true,
parallel: 0,
retry: suiteName === 'retry' ? 2 : 0,
retry: suite === 'retry' ? 2 : 0,
retryTagFilter: '',
strict: true,
worldParameters: {},
Expand All @@ -74,8 +74,10 @@ describe('Cucumber Compatibility Kit', () => {
stderr.end()

const expectedMessages: messages.Envelope[] = []
await asyncPipeline(
fs.createReadStream(fixturePath, { encoding: 'utf-8' }),
await pipeline(
fs.createReadStream(path.join(directory, suite + '.ndjson'), {
encoding: 'utf-8',
}),
new messageStreams.NdjsonToMessageStream(),
new Writable({
objectMode: true,
Expand All @@ -90,5 +92,5 @@ describe('Cucumber Compatibility Kit', () => {
.excludingEvery(ignorableKeys)
.to.deep.eq(expectedMessages)
})
})
}
})
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"yup": "1.6.1"
},
"devDependencies": {
"@cucumber/compatibility-kit": "19.0.0",
"@cucumber/compatibility-kit": "^20.0.0",
"@cucumber/pretty-formatter": "^2.0.0",
"@cucumber/query": "13.5.0",
"@eslint/compat": "^1.3.0",
Expand Down
Loading