@@ -3,9 +3,10 @@ import fs from "node:fs/promises";
33import path from "node:path" ;
44
55import { Then } from "@cucumber/cucumber" ;
6- import { findAllByText , findByText } from "@testing-library/dom" ;
6+ import { findByText } from "@testing-library/dom" ;
77import { JSDOM } from "jsdom" ;
88
9+ import { ensure } from "../../lib/helpers/assertions" ;
910import { findAllByAccordionComponent } from "../support/accordion" ;
1011import ICustomWorld from "../support/ICustomWorld" ;
1112
@@ -36,34 +37,26 @@ Then(
3637
3738Then (
3839 "the HTML should display {int} executed scenario(s)" ,
39- async function ( this : ICustomWorld , n : number ) {
40+ async function ( this : ICustomWorld , expected : number ) {
4041 const dom = await JSDOM . fromFile (
4142 path . join ( this . tmpDir , "cucumber-report.html" ) ,
4243 { runScripts : "dangerously" } ,
4344 ) ;
4445
4546 // configure({ defaultIgnore: "comments, script, style, link, g, path" });
4647
47- const AccordionItemButtons = await findAllByAccordionComponent (
48+ const dd = await findByText (
4849 dom . window . document . documentElement ,
49- "AccordionItemButton" ,
50+ / \d + % \( \d + \/ \d + \) p a s s e d / ,
51+ { selector : "span" } ,
5052 ) ;
5153
52- for ( const AccordionItemButton of AccordionItemButtons ) {
53- if (
54- AccordionItemButton . attributes . getNamedItem ( "aria-expanded" ) ?. value ===
55- "false"
56- ) {
57- AccordionItemButton . click ( ) ;
58- }
59- }
60-
61- const spans = await findAllByText (
62- dom . window . document . documentElement ,
63- / S c e n a r i o / ,
54+ const [ , actual ] = ensure (
55+ dd . textContent ! . match ( / \d + % \( \d + \/ ( \d + ) \) p a s s e d / ) ,
56+ "Expected a match" ,
6457 ) ;
6558
66- assert . equal ( spans . length , n ) ;
59+ assert . equal ( actual , expected ) ;
6760 } ,
6861) ;
6962
0 commit comments