@@ -4,58 +4,85 @@ import { makeTestHarness } from '../utils.js'
44import path from 'node:path'
55
66describe ( '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:
1213 Scenario:
1314 Given a step
1415 `
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'
1920 Given('a step', () => {})
2021 `
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+ } )
2627
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:
3233 Scenario:
3334 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'
3839Given('a step', () => {})
3940Given('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":
4445 1) ${ path . join ( 'features' , 'steps.js' ) } :2:1
4546 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+ } )
4662 } )
4763
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:
5370 Scenario:
5471 Given a step
5572 `
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+ } )
6087 } )
6188} )
0 commit comments