Skip to content

Update CCK test to work with new structure #89

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 5 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
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 @@ -42,7 +42,7 @@
"type-fest": "^4.33.0"
},
"devDependencies": {
"@cucumber/compatibility-kit": "^19.0.0",
"@cucumber/compatibility-kit": "^20.0.0",
"@eslint/compat": "^1.2.5",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.18.0",
Expand Down
34 changes: 19 additions & 15 deletions test/cck/cck.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import path from 'node:path'
import { expect, use } from 'chai'
import chaiExclude from 'chai-exclude'
import { makeTestHarness } from '../utils.js'
import { globSync } from 'node:fs'
import { Envelope } from '@cucumber/messages'
import { Env } from '@cucumber/ci-environment'
import { globby, globbySync } from 'globby'

use(chaiExclude)

Expand Down Expand Up @@ -43,27 +42,32 @@ const UNSUPPORTED = [
]

describe('Cucumber Compatibility Kit', () => {
const ndjsonPaths = globSync('node_modules/@cucumber/compatibility-kit/features/**/*.ndjson')
for (const ndjsonPath of ndjsonPaths) {
const [, name, extension] = /^.+[/\\](.+)(\.feature(?:\.md)?)\.ndjson$/.exec(
ndjsonPath
) as RegExpExecArray
const directories = globbySync('node_modules/@cucumber/compatibility-kit/features/*', {
onlyDirectories: true,
})
for (const directory of directories) {
const suite = path.basename(directory)

it(name, async function () {
if (UNSUPPORTED.includes(name)) {
it(suite, async function () {
if (UNSUPPORTED.includes(suite)) {
return this.skip()
}

const harness = await makeTestHarness()

await harness.copyDir(path.join(process.cwd(), 'test', 'cck', name), 'features')
await harness.copyFile(
path.join(CCK_PATH, 'features', name, name + extension),
path.join('features', name + extension)
)
await harness.copyDir(path.join(process.cwd(), 'test', 'cck', suite), 'features')
const featurePaths = await globby(['*.feature', '*.feature.md'], { cwd: directory })
for (const featurePath of featurePaths) {
await harness.copyFile(
path.join(CCK_PATH, 'features', suite, featurePath),
path.join('features', featurePath)
)
}

const [actualOutput] = await harness.run('@cucumber/node/reporters/message')
const expectedOutput = await readFile(ndjsonPath, { encoding: 'utf-8' })
const expectedOutput = await readFile(path.join(directory, suite + '.ndjson'), {
encoding: 'utf-8',
})

const actualEnvelopes = parseEnvelopes(actualOutput)
const expectedEnvelopes = parseEnvelopes(expectedOutput)
Expand Down
Loading