11import { describe , expect , it } from 'vitest' ;
2- import { Window } from 'happy-dom' ;
32import { pointToDevServer } from '../devHtmlPrerender' ;
43import {
54 fakeDevServer ,
65 fakeResolvedConfig ,
76} from '../../../../utils/testing/fake-objects' ;
87import { normalizePath } from '../../../../utils/paths' ;
98import { resolve } from 'node:path' ;
9+ import { parseHTML } from 'linkedom' ;
1010
1111describe ( 'Dev HTML Prerender Plugin' , ( ) => {
1212 describe ( 'pointToDevServer' , ( ) => {
@@ -32,9 +32,7 @@ describe('Dev HTML Prerender Plugin', () => {
3232 // URLs should not be changed
3333 [ 'https://example.com/style.css' , 'https://example.com/style.css' ] ,
3434 ] ) ( 'should transform "%s" into "%s"' , ( input , expected ) => {
35- const { document } = new Window ( {
36- url : 'http://localhost' ,
37- } ) ;
35+ const { document } = parseHTML ( '<html></html>' ) ;
3836 const root = '/some/root' ;
3937 const config = fakeResolvedConfig ( {
4038 root,
@@ -55,7 +53,7 @@ describe('Dev HTML Prerender Plugin', () => {
5553 const id = root + '/entrypoints/popup/index.html' ;
5654
5755 document . head . innerHTML = `<link rel="stylesheet" href="${ input } " />` ;
58- pointToDevServer ( config , server , id , document as any , 'link' , 'href' ) ;
56+ pointToDevServer ( config , server , id , document , 'link' , 'href' ) ;
5957
6058 const actual = document . querySelector ( 'link' ) ! ;
6159 expect ( actual . getAttribute ( 'href' ) ) . toBe ( expected ) ;
0 commit comments