1
+ import assert from 'node:assert/strict' ;
1
2
import { setTimeout } from 'node:timers/promises' ;
2
3
import { getGlobalVariable } from '../../utils/env' ;
3
4
import { appendToFile , replaceInFile , writeMultipleFiles } from '../../utils/fs' ;
@@ -68,15 +69,9 @@ export default async function () {
68
69
{
69
70
const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
70
71
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 / ) ;
80
75
}
81
76
82
77
await setTimeout ( 500 ) ;
@@ -90,9 +85,7 @@ export default async function () {
90
85
{
91
86
const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
92
87
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 / ) ;
96
89
}
97
90
98
91
await setTimeout ( 500 ) ;
@@ -106,9 +99,7 @@ export default async function () {
106
99
{
107
100
const response = await fetch ( `http://localhost:${ port } /main.js` ) ;
108
101
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 / ) ;
112
103
}
113
104
114
105
await setTimeout ( 500 ) ;
@@ -122,8 +113,6 @@ export default async function () {
122
113
{
123
114
const response = await fetch ( `http://localhost:${ port } /styles.css` ) ;
124
115
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 / ) ;
128
117
}
129
118
}
0 commit comments