1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
import * as esbuild from "esbuild" ;
2
3
import glob from "glob" ;
3
4
@@ -9,59 +10,54 @@ import glob from "glob";
9
10
10
11
console . log ( "Bundling tests..." ) ;
11
12
12
- // Bundles script to run tests on VSCode host + mocha runner that will be invoked from within VSCode host
13
- await esbuild . build ( {
14
- entryPoints : [
15
- // Runs mocha runner on VSCode host using runTests from @vscode /test-electron
16
- "src/test/runner/runTestOnVSCodeHost.ts" ,
17
-
18
- // Runs the bundled tests using Mocha class
19
- "src/test/runner/mochaRunner.ts" ,
20
- ] ,
13
+ const baseConfig = {
21
14
bundle : true ,
22
15
outdir : "out" ,
23
-
24
16
external : [
25
17
"vscode" ,
26
-
27
18
// Its important to externalize mocha, otherwise mocha seems to be not initialized properly when running tests
28
19
// Example warning by esbuild when mocha is not externalized:
29
20
// [WARNING] "./reporters/parallel-buffered" should be marked as external for use with "require.resolve" [require-resolve-not-external]
30
21
"mocha" ,
22
+ "esbuild" ,
23
+ "./xhr-sync-worker.js" ,
31
24
] ,
32
25
format : "cjs" ,
33
26
platform : "node" ,
34
27
sourcemap : true ,
35
28
loader : {
36
- // eslint-disable-next-line @typescript-eslint/naming-convention
37
29
".node" : "file" ,
38
30
} ,
39
- } ) ;
31
+ } ;
40
32
41
- /**
42
- * Note: Bundling is done to work around import issues, for example with fkill that does not provide cjs module.
43
- * Rather than figuring out a combination of tsconfig.json that would work, I decided to bundle tests instead.
44
- */
45
- await esbuild . build ( {
33
+ const runnerConfig = {
34
+ ...baseConfig ,
35
+ // Bundles script to run tests on VSCode host + mocha runner that will be invoked from within VSCode host
36
+ entryPoints : [
37
+ // Runs mocha runner on VSCode host using runTests from @vscode /test-electron
38
+ "src/test/runner/runTestOnVSCodeHost.ts" ,
39
+ // Runs the bundled tests using Mocha class
40
+ "src/test/runner/mochaRunner.ts" ,
41
+ ] ,
42
+ } ;
43
+
44
+ const testsConfig = {
45
+ ...baseConfig ,
46
46
// Tests can be added anywhere in src folder
47
47
entryPoints : glob . sync ( "src/**/*.test.ts" ) ,
48
- bundle : true ,
49
- outdir : "out" ,
50
- external : [
51
- "vscode" ,
52
-
53
- // Its important to externalize mocha, otherwise mocha seems to be not initialized properly when running tests
54
- "mocha" ,
55
- ] ,
56
- format : "cjs" ,
57
- platform : "node" ,
58
- sourcemap : true ,
59
- loader : {
60
- // eslint-disable-next-line @typescript-eslint/naming-convention
61
- ".node" : "file" ,
62
- } ,
63
48
// To allow import.meta.path for transformers.js
64
49
// https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483
65
50
inject : [ "./scripts/importMetaUrl.js" ] ,
66
51
define : { "import.meta.url" : "importMetaUrl" } ,
67
- } ) ;
52
+ } ;
53
+
54
+ // Build runner
55
+ await esbuild . build ( runnerConfig ) ;
56
+
57
+ /**
58
+ * Note: Bundling is done to work around import issues, for example with fkill that does not provide cjs module.
59
+ * Rather than figuring out a combination of tsconfig.json that would work, I decided to bundle tests instead.
60
+ *
61
+ * Build tests
62
+ */
63
+ await esbuild . build ( testsConfig ) ;
0 commit comments