1+ import assert from 'node:assert/strict' ;
12import { setTimeout } from 'node:timers/promises' ;
23import { getGlobalVariable } from '../../utils/env' ;
34import { appendToFile , replaceInFile , writeMultipleFiles } from '../../utils/fs' ;
@@ -68,15 +69,9 @@ export default async function () {
6869 {
6970 const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
7071 const body = await response . text ( ) ;
71- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 1 / ) ) {
72- throw new Error ( 'Expected golden value 1.' ) ;
73- }
74- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 2 / ) ) {
75- throw new Error ( 'Expected golden value 2.' ) ;
76- }
77- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 3 / ) ) {
78- throw new Error ( 'Expected golden value 3.' ) ;
79- }
72+ assert . match ( body , / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 1 / ) ;
73+ assert . match ( body , / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 2 / ) ;
74+ assert . match ( body , / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 3 / ) ;
8075 }
8176
8277 await setTimeout ( 500 ) ;
@@ -90,9 +85,7 @@ export default async function () {
9085 {
9186 const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
9287 const body = await response . text ( ) ;
93- if ( ! body . match ( / t e s t i n g T E S T I N G 1 2 3 / ) ) {
94- throw new Error ( 'Expected component HTML to update.' ) ;
95- }
88+ assert . match ( body , / t e s t i n g T E S T I N G 1 2 3 / ) ;
9689 }
9790
9891 await setTimeout ( 500 ) ;
@@ -106,9 +99,7 @@ export default async function () {
10699 {
107100 const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
108101 const body = await response . text ( ) ;
109- if ( ! body . match ( / c o l o r : \s ? b l u e / ) ) {
110- throw new Error ( 'Expected component CSS to update.' ) ;
111- }
102+ assert . match ( body , / c o l o r : \s ? b l u e / ) ;
112103 }
113104
114105 await setTimeout ( 500 ) ;
@@ -122,8 +113,6 @@ export default async function () {
122113 {
123114 const response = await fetch ( `http://localhost:${ port } /styles.css` ) ;
124115 const body = await response . text ( ) ;
125- if ( ! body . match ( / c o l o r : \s ? g r e e n / ) ) {
126- throw new Error ( 'Expected global CSS to update.' ) ;
127- }
116+ assert . match ( body , / c o l o r : \s ? g r e e n / ) ;
128117 }
129118}
0 commit comments