@@ -40,6 +40,34 @@ function parse(
4040 )
4141}
4242
43+ function verifyTandem (
44+ assertion : ( p1 : messages . IPickle , p2 : messages . IPickle ) => void
45+ ) {
46+ return function ( this : World ) : void {
47+ const running = new Set < string > ( )
48+ const pickles : Dictionary < messages . IPickle > = { }
49+ const testCases : Dictionary < string > = { }
50+ const testStarts : Dictionary < string > = { }
51+
52+ const handlers = defaultHandlers ( {
53+ pickles,
54+ running,
55+ testCases,
56+ testStarts,
57+ } )
58+ handlers . testCaseStarted = _ . wrap (
59+ handlers . testCaseStarted ,
60+ ( fn , t : messages . TestCaseStarted ) => {
61+ running . forEach ( ( tcId ) =>
62+ assertion ( pickles [ testCases [ tcId ] ] , pickles [ testCases [ t . testCaseId ] ] )
63+ )
64+ fn ( t )
65+ }
66+ )
67+ parse ( this . lastRun . envelopes , handlers )
68+ }
69+ }
70+
4371Then ( / ^ i t r u n s t e s t s i n o r d e r ( .+ ) $ / , function ( this : World , order : string ) {
4472 const running = new Set < string > ( )
4573 const pickles : Dictionary < messages . IPickle > = { }
@@ -52,31 +80,14 @@ Then(/^it runs tests in order (.+)$/, function (this: World, order: string) {
5280 parse ( this . lastRun . envelopes , handlers )
5381} )
5482
55- Then ( / ^ t a n d e m t e s t s v e r i f i e d $ / , function ( this : World , assertion : string ) {
56- const running = new Set < string > ( )
57- const pickles : Dictionary < messages . IPickle > = { }
58- const testCases : Dictionary < string > = { }
59- const testStarts : Dictionary < string > = { }
60- const assertFn = (
61- _pickle1 : messages . IPickle ,
62- _pickle2 : messages . IPickle
63- ) : boolean => {
64- // eslint-disable-next-line no-eval
65- return eval ( `
66- const { expect } = require('chai')
67- ${ assertion }
68- ` )
69- }
70-
71- const handlers = defaultHandlers ( { pickles, running, testCases, testStarts } )
72- handlers . testCaseStarted = _ . wrap (
73- handlers . testCaseStarted ,
74- ( fn , t : messages . TestCaseStarted ) => {
75- running . forEach ( ( tcId ) =>
76- assertFn ( pickles [ testCases [ tcId ] ] , pickles [ testCases [ t . testCaseId ] ] )
77- )
78- fn ( t )
79- }
83+ Then (
84+ / ^ n o t e s t s r a n i n t a n d e m $ / ,
85+ verifyTandem ( ( ) =>
86+ expect . fail ( 'No tests should have executed at the same time' )
8087 )
81- parse ( this . lastRun . envelopes , handlers )
82- } )
88+ )
89+
90+ Then (
91+ / ^ t a n d e m t e s t s h a v e u n i q u e f i r s t t a g $ / ,
92+ verifyTandem ( ( p1 , p2 ) => expect ( p1 . tags [ 0 ] . name ) . to . not . eq ( p2 . tags [ 0 ] . name ) )
93+ )
0 commit comments