Skip to content

Commit b5086c9

Browse files
authored
Update CCK test to work with new structure (#89)
1 parent 6b6f948 commit b5086c9

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"type-fest": "^4.33.0"
4343
},
4444
"devDependencies": {
45-
"@cucumber/compatibility-kit": "^19.0.0",
45+
"@cucumber/compatibility-kit": "^20.0.0",
4646
"@eslint/compat": "^1.2.5",
4747
"@eslint/eslintrc": "^3.2.0",
4848
"@eslint/js": "^9.18.0",

test/cck/cck.spec.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import path from 'node:path'
44
import { expect, use } from 'chai'
55
import chaiExclude from 'chai-exclude'
66
import { makeTestHarness } from '../utils.js'
7-
import { globSync } from 'node:fs'
87
import { Envelope } from '@cucumber/messages'
9-
import { Env } from '@cucumber/ci-environment'
8+
import { globby, globbySync } from 'globby'
109

1110
use(chaiExclude)
1211

@@ -43,27 +42,32 @@ const UNSUPPORTED = [
4342
]
4443

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

52-
it(name, async function () {
53-
if (UNSUPPORTED.includes(name)) {
51+
it(suite, async function () {
52+
if (UNSUPPORTED.includes(suite)) {
5453
return this.skip()
5554
}
5655

5756
const harness = await makeTestHarness()
5857

59-
await harness.copyDir(path.join(process.cwd(), 'test', 'cck', name), 'features')
60-
await harness.copyFile(
61-
path.join(CCK_PATH, 'features', name, name + extension),
62-
path.join('features', name + extension)
63-
)
58+
await harness.copyDir(path.join(process.cwd(), 'test', 'cck', suite), 'features')
59+
const featurePaths = await globby(['*.feature', '*.feature.md'], { cwd: directory })
60+
for (const featurePath of featurePaths) {
61+
await harness.copyFile(
62+
path.join(CCK_PATH, 'features', suite, featurePath),
63+
path.join('features', featurePath)
64+
)
65+
}
6466

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

6872
const actualEnvelopes = parseEnvelopes(actualOutput)
6973
const expectedEnvelopes = parseEnvelopes(expectedOutput)

0 commit comments

Comments
 (0)