@@ -8,14 +8,13 @@ import log from 'fancy-log';
8
8
import { buildJS , watchJS } from './rollup.js' ;
9
9
10
10
/**
11
- * Build a bundle of tests and run them using Karma .
11
+ * Build a bundle of tests and run them using Vitest .
12
12
*
13
13
* @param {object } options
14
14
* @param {string } options.bootstrapFile - Entry point for the test bundle that initializes the environment
15
15
* @param {string } options.rollupConfig - Rollup config that generates the test bundle using
16
16
* `${outputDir}/test-inputs.js` as an entry point
17
- * @param {string } [options.karmaConfig] - Karma config file. Will use karma to run tests
18
- * @param {string } [options.vitestConfig] - Vitest config file. Will use vitest to run tests
17
+ * @param {string } options.vitestConfig - Vitest config file.
19
18
* @param {string } options.outputDir - Directory in which to generate test bundle. Defaults to
20
19
* `build/scripts`
21
20
* @param {string } options.testsPattern - Minimatch pattern that specifies which test files to
@@ -26,7 +25,6 @@ export async function runTests({
26
25
bootstrapFile,
27
26
rollupConfig,
28
27
outputDir = 'build/scripts' ,
29
- karmaConfig,
30
28
vitestConfig,
31
29
testsPattern,
32
30
} ) {
@@ -67,43 +65,14 @@ export async function runTests({
67
65
await watchJS ( rollupConfig ) ;
68
66
}
69
67
70
- if ( karmaConfig ) {
71
- // Run the tests with karma.
72
- log ( 'Starting Karma...' ) ;
73
- const { default : karma } = await import ( 'karma' ) ;
74
- const parsedConfig = await karma . config . parseConfig (
75
- path . resolve ( karmaConfig ) ,
76
- { singleRun } ,
77
- ) ;
78
-
79
- return new Promise ( ( resolve , reject ) => {
80
- new karma . Server ( parsedConfig , exitCode => {
81
- if ( exitCode === 0 ) {
82
- resolve ( ) ;
83
- } else {
84
- reject ( new Error ( `Karma run failed with status ${ exitCode } ` ) ) ;
85
- }
86
- } ) . start ( ) ;
87
-
88
- process . on ( 'SIGINT' , ( ) => {
89
- // Give Karma a chance to handle SIGINT and cleanup, but forcibly
90
- // exit if it takes too long.
91
- setTimeout ( ( ) => {
92
- resolve ( ) ;
93
- process . exit ( 1 ) ;
94
- } , 5000 ) ;
95
- } ) ;
96
- } ) ;
97
- } else if ( vitestConfig ) {
98
- // Run the tests with vitest. Karma takes precedence if both are defined
99
- log ( 'Starting vitest...' ) ;
100
- const [ { startVitest } , vitestOptions ] = await Promise . all ( [
101
- import ( 'vitest/node' ) ,
102
- import ( path . resolve ( vitestConfig ) ) ,
103
- ] ) ;
104
- await startVitest ( 'test' , [ ] , {
105
- watch : live ,
106
- ...vitestOptions ,
107
- } ) ;
108
- }
68
+ // Run the tests with vitest
69
+ log ( 'Starting vitest...' ) ;
70
+ const [ { startVitest } , vitestOptions ] = await Promise . all ( [
71
+ import ( 'vitest/node' ) ,
72
+ import ( path . resolve ( vitestConfig ) ) ,
73
+ ] ) ;
74
+ await startVitest ( 'test' , [ ] , {
75
+ watch : live ,
76
+ ...vitestOptions ,
77
+ } ) ;
109
78
}
0 commit comments