@@ -3,37 +3,49 @@ import { readFile, run, runWatch } from '../../utils/test-utils';
33
44describe ( 'build command' , ( ) => {
55 it . concurrent ( 'it should work ' , async ( ) => {
6- const { exitCode, stderr, stdout } = await run ( __dirname , [ ] ) ;
6+ const { exitCode, stderr, stdout } = await run ( __dirname , [ ] , { } , { } , true ) ;
77 expect ( exitCode ) . toBe ( 0 ) ;
88 expect ( stderr ) . toBeFalsy ( ) ;
99 expect ( stdout ) . toBeTruthy ( ) ;
1010 } ) ;
1111 it . concurrent (
1212 'should work without command and options (default command)' ,
1313 async ( ) => {
14- const { exitCode, stderr, stdout } = await run ( __dirname , [
15- '--mode' ,
16- 'development' ,
17- ] ) ;
14+ const { exitCode, stderr, stdout } = await run (
15+ __dirname ,
16+ [ '--mode' , 'development' ] ,
17+ { } ,
18+ { } ,
19+ true ,
20+ ) ;
1821
1922 expect ( exitCode ) . toBe ( 0 ) ;
2023 expect ( stderr ) . toBeFalsy ( ) ;
2124 expect ( stdout ) . toBeTruthy ( ) ;
2225 } ,
2326 ) ;
2427 it . concurrent ( 'should work with configuration return function' , async ( ) => {
25- const { exitCode, stderr, stdout } = await run ( __dirname , [
26- '--config' ,
27- './entry.function.js' ,
28- ] ) ;
28+ const { exitCode, stderr, stdout } = await run (
29+ __dirname ,
30+ [ '--config' , './entry.function.js' ] ,
31+ { } ,
32+ { } ,
33+ true ,
34+ ) ;
2935 expect ( exitCode ) . toBe ( 0 ) ;
3036 expect ( stderr ) . toBeFalsy ( ) ;
3137 expect ( stdout ) . toBeTruthy ( ) ;
3238 } ) ;
3339 it . concurrent (
3440 'should pass env.RSPACK_BUILD and env.RSPACK_BUNDLE for function configuration on build mode' ,
3541 async ( ) => {
36- const { stdout } = await run ( __dirname , [ '--config' , './entry.env.js' ] ) ;
42+ const { stdout } = await run (
43+ __dirname ,
44+ [ '--config' , './entry.env.js' ] ,
45+ { } ,
46+ { } ,
47+ true ,
48+ ) ;
3749 expect ( stdout ) . toContain ( 'RSPACK_BUILD=true' ) ;
3850 expect ( stdout ) . toContain ( 'RSPACK_BUNDLE=true' ) ;
3951 expect ( stdout ) . not . toContain ( 'RSPACK_WATCH=true' ) ;
@@ -57,32 +69,44 @@ describe('build command', () => {
5769 } ,
5870 ) ;
5971 it . concurrent ( 'should work with configuration return promise' , async ( ) => {
60- const { exitCode, stderr, stdout } = await run ( __dirname , [
61- '--config' ,
62- './entry.promise.js' ,
63- ] ) ;
72+ const { exitCode, stderr, stdout } = await run (
73+ __dirname ,
74+ [ '--config' , './entry.promise.js' ] ,
75+ { } ,
76+ { } ,
77+ true ,
78+ ) ;
6479 expect ( exitCode ) . toBe ( 0 ) ;
6580 expect ( stderr ) . toBeFalsy ( ) ;
6681 expect ( stdout ) . toBeTruthy ( ) ;
6782 } ) ;
6883 it . concurrent ( 'should work with mjs configuration ' , async ( ) => {
69- const { exitCode, stderr, stdout } = await run ( __dirname , [
70- '--config' ,
71- './entry.config.mjs' ,
72- ] ) ;
84+ const { exitCode, stderr, stdout } = await run (
85+ __dirname ,
86+ [ '--config' , './entry.config.mjs' ] ,
87+ { } ,
88+ { } ,
89+ true ,
90+ ) ;
7391 expect ( exitCode ) . toBe ( 0 ) ;
7492 expect ( stderr ) . toBeFalsy ( ) ;
7593 expect ( stdout ) . toBeTruthy ( ) ;
7694 } ) ;
7795 it ( 'entry option should have higher priority than config' , async ( ) => {
78- const { exitCode, stderr, stdout } = await run ( __dirname , [
79- '--entry' ,
80- './src/other.js' ,
81- '--config' ,
82- './entry.config.js' ,
83- '--output-path' ,
84- 'dist/priority' ,
85- ] ) ;
96+ const { exitCode, stderr, stdout } = await run (
97+ __dirname ,
98+ [
99+ '--entry' ,
100+ './src/other.js' ,
101+ '--config' ,
102+ './entry.config.js' ,
103+ '--output-path' ,
104+ 'dist/priority' ,
105+ ] ,
106+ { } ,
107+ { } ,
108+ true ,
109+ ) ;
86110 const mainJs = await readFile (
87111 resolve ( __dirname , 'dist/priority/main.js' ) ,
88112 'utf-8' ,
@@ -98,12 +122,13 @@ describe('build command', () => {
98122 it . each ( [ '-o' , '--output-path' , '--outputPath' ] ) (
99123 'output-path option %s should have higher priority than config' ,
100124 async ( command ) => {
101- const { exitCode, stderr, stdout } = await run ( __dirname , [
102- command ,
103- 'dist/public' ,
104- '--config' ,
105- './entry.config.js' ,
106- ] ) ;
125+ const { exitCode, stderr, stdout } = await run (
126+ __dirname ,
127+ [ command , 'dist/public' , '--config' , './entry.config.js' ] ,
128+ { } ,
129+ { } ,
130+ true ,
131+ ) ;
107132 const mainJs = await readFile (
108133 resolve ( __dirname , 'dist/public/main.js' ) ,
109134 'utf-8' ,
@@ -126,15 +151,16 @@ describe('build command', () => {
126151 ] ) (
127152 'devtool option %s should have higher priority than config' ,
128153 async ( command , option ) => {
129- const { exitCode, stderr, stdout } = await run ( __dirname , [
130- command ,
131- option ,
132- '--config' ,
133- './entry.config.js' ,
134- ] ) ;
154+ const { exitCode, stderr, stdout } = await run (
155+ __dirname ,
156+ [ command , option , '--config' , './entry.config.js' ] ,
157+ { } ,
158+ { } ,
159+ true ,
160+ ) ;
135161
136162 const mainJs = await readFile (
137- resolve ( __dirname , 'dist/public/ main.js' ) ,
163+ resolve ( __dirname , 'dist/main.js' ) ,
138164 'utf-8' ,
139165 ) ;
140166
0 commit comments