1- import { BrowserLauncher , TestRunnerCoreConfig , TestSession } from '@web/test-runner-core' ;
1+ import assert from 'node:assert/strict' ;
2+ import { describe , before , it } from 'node:test' ;
3+ import type { BrowserLauncher , TestRunnerCoreConfig , TestSession } from '@web/test-runner-core' ;
24import { runTests } from '@web/test-runner-core/test-helpers' ;
35import { legacyPlugin } from '@web/dev-server-legacy' ;
46import { resolve } from 'path' ;
5- import { expect } from 'chai' ;
67
78export function runBasicTest (
89 config : Partial < TestRunnerCoreConfig > & { browsers : BrowserLauncher [ ] } ,
@@ -14,78 +15,93 @@ export function runBasicTest(
1415 before ( async ( ) => {
1516 const result = await runTests ( {
1617 ...config ,
17- files : [ ...( config . files ?? [ ] ) , resolve ( __dirname , 'browser-tests' , '*.test.js' ) ] ,
18+ files : [
19+ ...( config . files ?? [ ] ) ,
20+ resolve ( import . meta. dirname , 'browser-tests' , '*.test.js' ) ,
21+ ] ,
1822 plugins : [ ...( config . plugins ?? [ ] ) , legacyPlugin ( ) ] ,
1923 } ) ;
2024 allSessions = result . sessions ;
2125
22- expect ( allSessions . every ( s => s . passed ) ) . to . equal ( true , 'All sessions should have passed' ) ;
26+ assert . equal (
27+ allSessions . every ( s => s . passed ) ,
28+ true ,
29+ 'All sessions should have passed' ,
30+ ) ;
2331 } ) ;
2432
2533 it ( 'passes basic test' , ( ) => {
2634 const sessions = allSessions . filter ( s => s . testFile . endsWith ( 'basic.test.js' ) ) ;
27- expect ( sessions . length === browserCount ) . to . equal (
28- true ,
29- 'Each browser should run basic.test.js' ,
30- ) ;
35+ assert . equal ( sessions . length === browserCount , true , 'Each browser should run basic.test.js' ) ;
3136 for ( const session of sessions ) {
32- expect ( session . testResults ! . tests . length ) . to . equal ( 0 ) ;
33- expect ( session . testResults ! . suites . length ) . to . equal ( 1 ) ;
34- expect ( session . testResults ! . suites [ 0 ] . tests . length ) . to . equal ( 1 ) ;
35- expect ( session . testResults ! . suites [ 0 ] . tests . map ( t => t . name ) ) . to . eql ( [ 'works' ] ) ;
37+ assert . equal ( session . testResults ! . tests . length , 0 ) ;
38+ assert . equal ( session . testResults ! . suites . length , 1 ) ;
39+ assert . equal ( session . testResults ! . suites [ 0 ] . tests . length , 1 ) ;
40+ assert . deepEqual (
41+ session . testResults ! . suites [ 0 ] . tests . map ( t => t . name ) ,
42+ [ 'works' ] ,
43+ ) ;
3644 }
3745 } ) ;
3846
3947 it ( 'passes js-syntax test' , ( ) => {
4048 const sessions = allSessions . filter ( s => s . testFile . endsWith ( 'js-syntax.test.js' ) ) ;
41- expect ( sessions . length === browserCount ) . to . equal (
49+ assert . equal (
50+ sessions . length === browserCount ,
4251 true ,
4352 'Each browser should run js-syntax.test.js' ,
4453 ) ;
4554 for ( const session of sessions ) {
46- expect ( session . testResults ! . tests . map ( t => t . name ) ) . to . eql ( [
47- 'supports object spread' ,
48- 'supports async functions' ,
49- 'supports exponentiation' ,
50- 'supports classes' ,
51- 'supports template literals' ,
52- 'supports optional chaining' ,
53- 'supports nullish coalescing' ,
54- ] ) ;
55+ assert . deepEqual (
56+ session . testResults ! . tests . map ( t => t . name ) ,
57+ [
58+ 'supports object spread' ,
59+ 'supports async functions' ,
60+ 'supports exponentiation' ,
61+ 'supports classes' ,
62+ 'supports template literals' ,
63+ 'supports optional chaining' ,
64+ 'supports nullish coalescing' ,
65+ ] ,
66+ ) ;
5567 }
5668 } ) ;
5769
5870 it ( 'passes module-features test' , ( ) => {
5971 const sessions = allSessions . filter ( s => s . testFile . endsWith ( 'module-features.test.js' ) ) ;
60- expect ( sessions . length === browserCount ) . to . equal (
72+ assert . equal (
73+ sessions . length === browserCount ,
6174 true ,
6275 'Each browser should run module-features.test.js' ,
6376 ) ;
6477 for ( const session of sessions ) {
65- expect ( session . testResults ! . tests . map ( t => t . name ) ) . to . eql ( [
66- 'supports static imports' ,
67- 'supports dynamic imports' ,
68- 'supports import meta' ,
69- ] ) ;
78+ assert . deepEqual (
79+ session . testResults ! . tests . map ( t => t . name ) ,
80+ [ 'supports static imports' , 'supports dynamic imports' , 'supports import meta' ] ,
81+ ) ;
7082 }
7183 } ) ;
7284
7385 it ( 'passes timers test' , ( ) => {
7486 const sessions = allSessions . filter ( s => s . testFile . endsWith ( 'timers.test.js' ) ) ;
75- expect ( sessions . length === browserCount ) . to . equal (
87+ assert . equal (
88+ sessions . length === browserCount ,
7689 true ,
7790 'Each browser should run timers.test.js' ,
7891 ) ;
7992 for ( const session of sessions ) {
80- expect ( session . testResults ! . tests . length ) . to . equal ( 0 ) ;
81- expect ( session . testResults ! . suites . length ) . to . equal ( 1 ) ;
82- expect ( session . testResults ! . suites [ 0 ] . tests . map ( t => t . name ) ) . to . eql ( [
83- 'can call setTimeout' ,
84- 'can cancel setTimeout' ,
85- 'can call and cancel setInterval' ,
86- 'can call requestAnimationFrame' ,
87- 'can cancel requestAnimationFrame' ,
88- ] ) ;
93+ assert . equal ( session . testResults ! . tests . length , 0 ) ;
94+ assert . equal ( session . testResults ! . suites . length , 1 ) ;
95+ assert . deepEqual (
96+ session . testResults ! . suites [ 0 ] . tests . map ( t => t . name ) ,
97+ [
98+ 'can call setTimeout' ,
99+ 'can cancel setTimeout' ,
100+ 'can call and cancel setInterval' ,
101+ 'can call requestAnimationFrame' ,
102+ 'can cancel requestAnimationFrame' ,
103+ ] ,
104+ ) ;
89105 }
90106 } ) ;
91107 } ) ;
0 commit comments