@@ -19,6 +19,19 @@ async function run(events) {
1919 return { text : buffer , code }
2020}
2121
22+ // Same as run(), with --verbose so the log and HTML state blocks are rendered.
23+ async function runVerbose ( events ) {
24+ let buffer = ''
25+ let receiver = createReceiver ( {
26+ verbose : true ,
27+ remapper : noRemap ,
28+ serverURL : 'http://localhost:4000' ,
29+ out : { write : ( string ) => { buffer += string } } ,
30+ } )
31+ for ( let event of events ) await receiver . handle ( event )
32+ return { text : buffer }
33+ }
34+
2235test ( 'prints live progress and a passing summary, exit 0' , async ( ) => {
2336 let { text, code } = await run ( [
2437 { type : 'jasmineStarted' , totalSpecs : 2 } ,
@@ -152,3 +165,43 @@ test('a filter that matched nothing fails instead of reporting success', async (
152165 assert . equal ( code , 1 )
153166 assert . match ( text , / N o s p e c s r a n / )
154167} )
168+
169+ test ( 'a teardown snapshot is labelled so it is not mistaken for the failure-time DOM' , async ( ) => {
170+ // A spec that passes its expectations and then dies in teardown gets its snapshot late,
171+ // after #fixtures has been destroyed — so the heading has to say so.
172+ let { text } = await runVerbose ( [
173+ { type : 'suiteStarted' , description : 'up.layer' } ,
174+ {
175+ type : 'specDone' ,
176+ fullName : 'up.layer leaks an overlay' ,
177+ description : 'leaks an overlay' ,
178+ status : 'failed' ,
179+ failedExpectations : [ { message : 'Overlays survived reset!' , stack : 'at reset_up.js:140' } ] ,
180+ failure : { log : [ ] , dom : [ { tag : 'up-modal' , classes : [ ] , attrs : { } , children : [ ] } ] , domAt : 'teardown' } ,
181+ } ,
182+ { type : 'suiteDone' , description : 'up.layer' , failedExpectations : [ ] } ,
183+ { type : 'jasmineDone' , overallStatus : 'failed' } ,
184+ ] )
185+
186+ assert . match ( text , / H T M L s t a t e \( a f t e r t e a r d o w n / )
187+ assert . match ( text , / u p - m o d a l / )
188+ } )
189+
190+ test ( 'a failure-time snapshot keeps the plain heading' , async ( ) => {
191+ let { text } = await runVerbose ( [
192+ { type : 'suiteStarted' , description : 'up.layer' } ,
193+ {
194+ type : 'specDone' ,
195+ fullName : 'up.layer fails an expectation' ,
196+ description : 'fails an expectation' ,
197+ status : 'failed' ,
198+ failedExpectations : [ { message : 'Expected 1 to be 2.' , stack : 'at spec/unpoly/layer_spec.js:5' } ] ,
199+ failure : { log : [ ] , dom : [ { tag : 'div' , id : 'fixtures' , classes : [ ] , attrs : { } , children : [ ] } ] , domAt : 'failure' } ,
200+ } ,
201+ { type : 'suiteDone' , description : 'up.layer' , failedExpectations : [ ] } ,
202+ { type : 'jasmineDone' , overallStatus : 'failed' } ,
203+ ] )
204+
205+ assert . match ( text , / H T M L s t a t e : / )
206+ assert . doesNotMatch ( text , / a f t e r t e a r d o w n / )
207+ } )
0 commit comments