1
1
import fs from 'node:fs'
2
2
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 '
5
5
import { describe , it } from 'mocha'
6
6
import { config , expect , use } from 'chai'
7
7
import chaiExclude from 'chai-exclude'
@@ -12,7 +12,6 @@ import { Envelope } from '@cucumber/messages'
12
12
import { ignorableKeys } from '../features/support/formatter_output_helpers'
13
13
import { runCucumber , IRunConfiguration } from '../src/api'
14
14
15
- const asyncPipeline = util . promisify ( pipeline )
16
15
const PROJECT_PATH = path . join ( __dirname , '..' )
17
16
const CCK_FEATURES_PATH = 'node_modules/@cucumber/compatibility-kit/features'
18
17
const CCK_IMPLEMENTATIONS_PATH = 'compatibility/features'
@@ -21,35 +20,36 @@ config.truncateThreshold = 100
21
20
use ( chaiExclude )
22
21
23
22
describe ( 'Cucumber Compatibility Kit' , ( ) => {
24
- const ndjsonFiles = glob . sync ( `${ CCK_FEATURES_PATH } /**/*.ndjson` )
25
- ndjsonFiles . forEach ( ( fixturePath ) => {
26
- const match = / ^ . + [ / \\ ] ( . + ) ( \. f e a t u r e (?: \. m d ) ? ) \. n d j s o n $ / . 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 ( ) => {
30
29
const actualMessages : Envelope [ ] = [ ]
31
30
const stdout = new PassThrough ( )
32
31
const stderr = new PassThrough ( )
33
32
const runConfiguration : IRunConfiguration = {
34
33
sources : {
35
34
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
+ ] ,
37
39
names : [ ] ,
38
40
tagExpression : '' ,
39
41
order : 'defined' ,
40
42
} ,
41
43
support : {
42
44
requireModules : [ 'ts-node/register' ] ,
43
- requirePaths : [
44
- `${ CCK_IMPLEMENTATIONS_PATH } /${ suiteName } /${ suiteName } .ts` ,
45
- ] ,
45
+ requirePaths : [ `${ CCK_IMPLEMENTATIONS_PATH } /${ suite } /*.ts` ] ,
46
46
} ,
47
47
runtime : {
48
48
dryRun : false ,
49
49
failFast : false ,
50
50
filterStacktraces : true ,
51
51
parallel : 0 ,
52
- retry : suiteName === 'retry' ? 2 : 0 ,
52
+ retry : suite === 'retry' ? 2 : 0 ,
53
53
retryTagFilter : '' ,
54
54
strict : true ,
55
55
worldParameters : { } ,
@@ -74,8 +74,10 @@ describe('Cucumber Compatibility Kit', () => {
74
74
stderr . end ( )
75
75
76
76
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
+ } ) ,
79
81
new messageStreams . NdjsonToMessageStream ( ) ,
80
82
new Writable ( {
81
83
objectMode : true ,
@@ -90,5 +92,5 @@ describe('Cucumber Compatibility Kit', () => {
90
92
. excludingEvery ( ignorableKeys )
91
93
. to . deep . eq ( expectedMessages )
92
94
} )
93
- } )
95
+ }
94
96
} )
0 commit comments