Skip to content

Commit 8f7ae8f

Browse files
authored
Update CCK test to work with new structure (#2602)
1 parent fc905cd commit 8f7ae8f

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

compatibility/cck_spec.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
3-
import { PassThrough, pipeline, Writable } from 'node:stream'
4-
import util from 'node:util'
3+
import { PassThrough, Writable } from 'node:stream'
4+
import { pipeline } from 'node:stream/promises'
55
import { describe, it } from 'mocha'
66
import { config, expect, use } from 'chai'
77
import chaiExclude from 'chai-exclude'
@@ -12,7 +12,6 @@ import { Envelope } from '@cucumber/messages'
1212
import { ignorableKeys } from '../features/support/formatter_output_helpers'
1313
import { runCucumber, IRunConfiguration } from '../src/api'
1414

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

2322
describe('Cucumber Compatibility Kit', () => {
24-
const ndjsonFiles = glob.sync(`${CCK_FEATURES_PATH}/**/*.ndjson`)
25-
ndjsonFiles.forEach((fixturePath) => {
26-
const match = /^.+[/\\](.+)(\.feature(?:\.md)?)\.ndjson$/.exec(fixturePath)
27-
const suiteName = match[1]
28-
const extension = match[2]
29-
it(`passes the cck suite for '${suiteName}'`, async () => {
23+
const directories = glob.sync(`${CCK_FEATURES_PATH}/*`, { nodir: false })
24+
25+
for (const directory of directories) {
26+
const suite = path.basename(directory)
27+
28+
it(suite, async () => {
3029
const actualMessages: Envelope[] = []
3130
const stdout = new PassThrough()
3231
const stderr = new PassThrough()
3332
const runConfiguration: IRunConfiguration = {
3433
sources: {
3534
defaultDialect: 'en',
36-
paths: [`${CCK_FEATURES_PATH}/${suiteName}/${suiteName}${extension}`],
35+
paths: [
36+
`${CCK_FEATURES_PATH}/${suite}/*.feature`,
37+
`${CCK_FEATURES_PATH}/${suite}/*.feature.md`,
38+
],
3739
names: [],
3840
tagExpression: '',
3941
order: 'defined',
4042
},
4143
support: {
4244
requireModules: ['ts-node/register'],
43-
requirePaths: [
44-
`${CCK_IMPLEMENTATIONS_PATH}/${suiteName}/${suiteName}.ts`,
45-
],
45+
requirePaths: [`${CCK_IMPLEMENTATIONS_PATH}/${suite}/*.ts`],
4646
},
4747
runtime: {
4848
dryRun: false,
4949
failFast: false,
5050
filterStacktraces: true,
5151
parallel: 0,
52-
retry: suiteName === 'retry' ? 2 : 0,
52+
retry: suite === 'retry' ? 2 : 0,
5353
retryTagFilter: '',
5454
strict: true,
5555
worldParameters: {},
@@ -74,8 +74,10 @@ describe('Cucumber Compatibility Kit', () => {
7474
stderr.end()
7575

7676
const expectedMessages: messages.Envelope[] = []
77-
await asyncPipeline(
78-
fs.createReadStream(fixturePath, { encoding: 'utf-8' }),
77+
await pipeline(
78+
fs.createReadStream(path.join(directory, suite + '.ndjson'), {
79+
encoding: 'utf-8',
80+
}),
7981
new messageStreams.NdjsonToMessageStream(),
8082
new Writable({
8183
objectMode: true,
@@ -90,5 +92,5 @@ describe('Cucumber Compatibility Kit', () => {
9092
.excludingEvery(ignorableKeys)
9193
.to.deep.eq(expectedMessages)
9294
})
93-
})
95+
}
9496
})

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
@@ -258,7 +258,7 @@
258258
"yup": "1.6.1"
259259
},
260260
"devDependencies": {
261-
"@cucumber/compatibility-kit": "19.0.0",
261+
"@cucumber/compatibility-kit": "^20.0.0",
262262
"@cucumber/pretty-formatter": "^2.0.0",
263263
"@cucumber/query": "13.5.0",
264264
"@eslint/compat": "^1.3.0",

0 commit comments

Comments
 (0)