1- import { expect } from 'chai' ;
1+ import { describe , it } from 'node:test' ;
2+ import assert from 'node:assert/strict' ;
23import { createTestServer } from '@web/dev-server-core/test-helpers' ;
34import { fetchText , expectIncludes } from '@web/dev-server-core/test-helpers' ;
45
5- import { legacyPlugin } from '../src/legacyPlugin.js' ;
6- import { modernUserAgents , legacyUserAgents } from './userAgents.js' ;
6+ // rewrite to ../src/legacyPlugin.ts when TS 5.7+ / rewriteRelativeImportExtensions
7+ import { legacyPlugin } from '../dist/legacyPlugin.js' ;
8+ import { modernUserAgents , legacyUserAgents } from './userAgents.ts' ;
79
810const htmlBody = `
911<html>
@@ -25,12 +27,10 @@ const inlineScriptHtmlBody = `
2527</body>
2628</html>` ;
2729
28- describe ( 'legacyPlugin - transform html' , function ( ) {
29- this . timeout ( 10000 ) ;
30-
30+ describe ( 'legacyPlugin - transform html' , { timeout : 10000 } , ( ) => {
3131 it ( `does not do any work on a modern browser` , async ( ) => {
3232 const { server, host } = await createTestServer ( {
33- rootDir : __dirname ,
33+ rootDir : import . meta . dirname ,
3434 plugins : [
3535 {
3636 name : 'test' ,
@@ -48,13 +48,13 @@ describe('legacyPlugin - transform html', function () {
4848 headers : { 'user-agent' : modernUserAgents [ 'Chrome 78' ] } ,
4949 } ) ;
5050
51- expect ( text . trim ( ) ) . to . equal ( htmlBody . trim ( ) ) ;
51+ assert . equal ( text . trim ( ) , htmlBody . trim ( ) ) ;
5252 server . stop ( ) ;
5353 } ) ;
5454
5555 it ( `injects polyfills into the HTML page on legacy browsers` , async ( ) => {
5656 const { server, host } = await createTestServer ( {
57- rootDir : __dirname ,
57+ rootDir : import . meta . dirname ,
5858 plugins : [
5959 {
6060 name : 'test' ,
@@ -80,7 +80,7 @@ describe('legacyPlugin - transform html', function () {
8080
8181 it ( `injects systemjs param to inline modules` , async ( ) => {
8282 const { server, host } = await createTestServer ( {
83- rootDir : __dirname ,
83+ rootDir : import . meta . dirname ,
8484 plugins : [
8585 {
8686 name : 'test' ,
@@ -104,7 +104,7 @@ describe('legacyPlugin - transform html', function () {
104104
105105 it ( `handles inline scripts` , async ( ) => {
106106 const { server, host } = await createTestServer ( {
107- rootDir : __dirname ,
107+ rootDir : import . meta . dirname ,
108108 plugins : [
109109 {
110110 name : 'test' ,
@@ -131,7 +131,7 @@ describe('legacyPlugin - transform html', function () {
131131
132132 it ( `can request inline scripts` , async ( ) => {
133133 const { server, host } = await createTestServer ( {
134- rootDir : __dirname ,
134+ rootDir : import . meta . dirname ,
135135 plugins : [
136136 {
137137 name : 'test' ,
@@ -158,7 +158,7 @@ describe('legacyPlugin - transform html', function () {
158158
159159 it ( `includes url parameters in inline script key` , async ( ) => {
160160 const { server, host } = await createTestServer ( {
161- rootDir : __dirname ,
161+ rootDir : import . meta . dirname ,
162162 plugins : [
163163 {
164164 name : 'test' ,
0 commit comments