@@ -210,8 +210,40 @@ if (!isBuild) {
210210 . poll ( async ( ) => JSON . parse ( await resultElement . textContent ( ) ) )
211211 . toStrictEqual ( [ '/pkg-pages/foo.js' ] )
212212 } )
213+
214+ test ( 'hmr for adding/removing files with array patterns and exclusions' , async ( ) => {
215+ const resultElement = page . locator ( '.array-result' )
216+ await expect
217+ . poll ( async ( ) => JSON . parse ( await resultElement . textContent ( ) ) )
218+ . toStrictEqual ( {
219+ './array-test-dir/included.js' : 'included' ,
220+ } )
221+
222+ addFile ( 'array-test-dir/new-file.js' , 'export default "new"' )
223+ await expect
224+ . poll ( async ( ) => JSON . parse ( await resultElement . textContent ( ) ) )
225+ . toStrictEqual ( {
226+ './array-test-dir/included.js' : 'included' ,
227+ './array-test-dir/new-file.js' : 'new' ,
228+ } )
229+
230+ removeFile ( 'array-test-dir/new-file.js' )
231+ await expect
232+ . poll ( async ( ) => JSON . parse ( await resultElement . textContent ( ) ) )
233+ . toStrictEqual ( {
234+ './array-test-dir/included.js' : 'included' ,
235+ } )
236+ } )
213237}
214238
239+ test ( 'array pattern with exclusions' , async ( ) => {
240+ await expect
241+ . poll ( async ( ) => JSON . parse ( await page . textContent ( '.array-result' ) ) )
242+ . toStrictEqual ( {
243+ './array-test-dir/included.js' : 'included' ,
244+ } )
245+ } )
246+
215247test ( 'tree-shake eager css' , async ( ) => {
216248 expect ( await page . textContent ( '.no-tree-shake-eager-css-result' ) ) . toMatch (
217249 '.no-tree-shake-eager-css' ,
@@ -237,26 +269,34 @@ test('escapes special chars in globs without mangling user supplied glob suffix'
237269 . filter ( ( f ) => f . isDirectory ( ) )
238270 . map ( ( f ) => `/escape/${ f . name } /glob.js` )
239271 . sort ( )
240- const foundRelativeNames = ( await page . textContent ( '.escape-relative' ) )
241- . split ( '\n' )
242- . sort ( )
243- expect ( expectedNames ) . toEqual ( foundRelativeNames )
244- const foundAliasNames = ( await page . textContent ( '.escape-alias' ) )
245- . split ( '\n' )
246- . sort ( )
247- expect ( expectedNames ) . toEqual ( foundAliasNames )
272+ await expect
273+ . poll ( async ( ) => {
274+ const text = await page . textContent ( '.escape-relative' )
275+ return text . split ( '\n' ) . sort ( )
276+ } )
277+ . toEqual ( expectedNames )
278+ await expect
279+ . poll ( async ( ) => {
280+ const text = await page . textContent ( '.escape-alias' )
281+ return text . split ( '\n' ) . sort ( )
282+ } )
283+ . toEqual ( expectedNames )
248284} )
249285
250286test ( 'subpath imports' , async ( ) => {
251- expect ( await page . textContent ( '.subpath-imports' ) ) . toMatch ( 'bar foo' )
287+ await expect
288+ . poll ( async ( ) => await page . textContent ( '.subpath-imports' ) )
289+ . toMatch ( 'bar foo' )
252290} )
253291
254292test ( '#alias imports' , async ( ) => {
255- expect ( await page . textContent ( '.hash-alias-imports' ) ) . toMatch ( 'bar foo' )
293+ await expect
294+ . poll ( async ( ) => await page . textContent ( '.hash-alias-imports' ) )
295+ . toMatch ( 'bar foo' )
256296} )
257297
258298test ( 'import base glob raw' , async ( ) => {
259- expect ( await page . textContent ( '.result-base' ) ) . toBe (
260- JSON . stringify ( baseRawResult , null , 2 ) ,
261- )
299+ await expect
300+ . poll ( async ( ) => await page . textContent ( '.result-base' ) )
301+ . toBe ( JSON . stringify ( baseRawResult , null , 2 ) )
262302} )
0 commit comments