@@ -4,58 +4,85 @@ import { makeTestHarness } from '../utils.js'
4
4
import path from 'node:path'
5
5
6
6
describe ( 'Reporters' , ( ) => {
7
- it ( 'does not emit messages as diagnostics if no cucumber reporters' , async ( ) => {
8
- const harness = await makeTestHarness ( )
9
- await harness . writeFile (
10
- 'features/first.feature' ,
11
- `Feature:
7
+ describe ( 'spec' , ( ) => {
8
+ it ( 'does not emit messages as diagnostics if no cucumber reporters' , async ( ) => {
9
+ const harness = await makeTestHarness ( )
10
+ await harness . writeFile (
11
+ 'features/first.feature' ,
12
+ `Feature:
12
13
Scenario:
13
14
Given a step
14
15
`
15
- )
16
- await harness . writeFile (
17
- 'features/steps.js' ,
18
- `import { Given } from '@cucumber/node'
16
+ )
17
+ await harness . writeFile (
18
+ 'features/steps.js' ,
19
+ `import { Given } from '@cucumber/node'
19
20
Given('a step', () => {})
20
21
`
21
- )
22
- const [ output ] = await harness . run ( 'spec' )
23
- const sanitised = stripVTControlCharacters ( output . trim ( ) )
24
- expect ( sanitised ) . not . to . include ( '@cucumber/messages:' )
25
- } )
22
+ )
23
+ const [ output ] = await harness . run ( 'spec' )
24
+ const sanitised = stripVTControlCharacters ( output . trim ( ) )
25
+ expect ( sanitised ) . not . to . include ( '@cucumber/messages:' )
26
+ } )
26
27
27
- it ( 'provides a useful error for an ambiguous step' , async ( ) => {
28
- const harness = await makeTestHarness ( )
29
- await harness . writeFile (
30
- 'features/first.feature' ,
31
- `Feature:
28
+ it ( 'provides a useful error for an ambiguous step' , async ( ) => {
29
+ const harness = await makeTestHarness ( )
30
+ await harness . writeFile (
31
+ 'features/first.feature' ,
32
+ `Feature:
32
33
Scenario:
33
34
Given a step`
34
- )
35
- await harness . writeFile (
36
- 'features/steps.js' ,
37
- `import { Given } from '@cucumber/node'
35
+ )
36
+ await harness . writeFile (
37
+ 'features/steps.js' ,
38
+ `import { Given } from '@cucumber/node'
38
39
Given('a step', () => {})
39
40
Given('a step', () => {})`
40
- )
41
- const [ output ] = await harness . run ( 'spec' )
42
- const sanitised = stripVTControlCharacters ( output . trim ( ) )
43
- expect ( sanitised ) . to . include ( `Multiple matching step definitions found for text "a step":
41
+ )
42
+ const [ output ] = await harness . run ( 'spec' )
43
+ const sanitised = stripVTControlCharacters ( output . trim ( ) )
44
+ expect ( sanitised ) . to . include ( `Multiple matching step definitions found for text "a step":
44
45
1) ${ path . join ( 'features' , 'steps.js' ) } :2:1
45
46
2) ${ path . join ( 'features' , 'steps.js' ) } :3:1` )
47
+ } )
48
+
49
+ it ( 'provides a useful error for an undefined step' , async ( ) => {
50
+ const harness = await makeTestHarness ( )
51
+ await harness . writeFile (
52
+ 'features/first.feature' ,
53
+ `Feature:
54
+ Scenario:
55
+ Given a step
56
+ `
57
+ )
58
+ const [ output ] = await harness . run ( 'spec' )
59
+ const sanitised = stripVTControlCharacters ( output . trim ( ) )
60
+ expect ( sanitised ) . to . include ( 'No matching step definitions found for text "a step"' )
61
+ } )
46
62
} )
47
63
48
- it ( 'provides a useful error for an undefined step' , async ( ) => {
49
- const harness = await makeTestHarness ( )
50
- await harness . writeFile (
51
- 'features/first.feature' ,
52
- `Feature:
64
+ describe ( 'junit' , ( ) => {
65
+ it ( 'outputs a junit xml report' , async ( ) => {
66
+ const harness = await makeTestHarness ( )
67
+ await harness . writeFile (
68
+ 'features/first.feature' ,
69
+ `Feature:
53
70
Scenario:
54
71
Given a step
55
72
`
56
- )
57
- const [ output ] = await harness . run ( 'spec' )
58
- const sanitised = stripVTControlCharacters ( output . trim ( ) )
59
- expect ( sanitised ) . to . include ( 'No matching step definitions found for text "a step"' )
73
+ )
74
+ await harness . writeFile (
75
+ 'features/steps.js' ,
76
+ `import { Given } from '@cucumber/node'
77
+ Given('a step', () => {})
78
+ `
79
+ )
80
+
81
+ const [ output ] = await harness . run ( '@cucumber/node/reporters/junit' )
82
+
83
+ expect ( output ) . to . include (
84
+ '<system-out><![CDATA[Given a step................................................................passed]]></system-out>'
85
+ )
86
+ } )
60
87
} )
61
88
} )
0 commit comments