@@ -91,42 +91,60 @@ describe("--target flag", () => {
91
91
expect ( stdout ) . toContain ( `target: [ 'node', 'async-node' ]` ) ;
92
92
} ) ;
93
93
94
- it ( "should throw an error for invalid target in multiple syntax" , async ( ) => {
94
+ it ( "should reset the `target` option when the `--target-reset` is used" , async ( ) => {
95
+ const { exitCode, stderr, stdout } = await run ( __dirname , [
96
+ "--config" ,
97
+ "target.web.config.js" ,
98
+ "--target-reset" ,
99
+ "--target" ,
100
+ "node" ,
101
+ ] ) ;
102
+
103
+ expect ( exitCode ) . toBe ( 0 ) ;
104
+ expect ( normalizeStderr ( stderr ) ) . toMatchSnapshot ( "stderr" ) ;
105
+ expect ( stdout ) . toContain ( `target: [ 'node' ]` ) ;
106
+ } ) ;
107
+
108
+ it ( "should reset the `target` option when the `--target-reset` is used for multiple targets" , async ( ) => {
95
109
const { exitCode, stderr, stdout } = await run ( __dirname , [
110
+ "--config" ,
111
+ "multiple-target.config.js" ,
112
+ "--target-reset" ,
96
113
"--target" ,
97
114
"node" ,
98
115
"--target" ,
99
- "invalid " ,
116
+ "async-node " ,
100
117
] ) ;
101
118
102
- expect ( exitCode ) . toBe ( 2 ) ;
119
+ expect ( exitCode ) . toBe ( 0 ) ;
103
120
expect ( normalizeStderr ( stderr ) ) . toMatchSnapshot ( "stderr" ) ;
104
- expect ( normalizeStdout ( stdout ) ) . toMatchSnapshot ( "stdout" ) ;
121
+ expect ( stdout ) . toContain ( `target: [ 'node', 'async-node' ]` ) ;
105
122
} ) ;
106
123
107
- it ( "should throw an error for incompatible multiple targets " , async ( ) => {
124
+ it ( "should throw an error for invalid target in multiple syntax " , async ( ) => {
108
125
const { exitCode, stderr, stdout } = await run ( __dirname , [
109
126
"--target" ,
110
127
"node" ,
111
128
"--target" ,
112
- "web " ,
129
+ "invalid " ,
113
130
] ) ;
114
131
115
132
expect ( exitCode ) . toBe ( 2 ) ;
116
133
expect ( normalizeStderr ( stderr ) ) . toMatchSnapshot ( "stderr" ) ;
117
134
expect ( normalizeStdout ( stdout ) ) . toMatchSnapshot ( "stdout" ) ;
118
135
} ) ;
119
136
120
- it ( "should reset target from node to async-node with --target-reset " , async ( ) => {
137
+ it ( "should throw an error for incompatible multiple targets " , async ( ) => {
121
138
const { exitCode, stderr, stdout } = await run ( __dirname , [
122
- "--target-reset" ,
123
139
"--target" ,
124
- "async-node" ,
140
+ "node" ,
141
+ "--target" ,
142
+ "web" ,
125
143
] ) ;
126
144
127
- expect ( exitCode ) . toBe ( 0 ) ;
145
+ expect ( exitCode ) . toBe ( 2 ) ;
128
146
expect ( normalizeStderr ( stderr ) ) . toMatchSnapshot ( "stderr" ) ;
129
- expect ( stdout ) . toContain ( `target: [ 'async-node' ]` ) ;
147
+ expect ( normalizeStdout ( stdout ) ) . toMatchSnapshot ( "stdout" ) ;
130
148
} ) ;
131
149
132
150
it ( "should throw error if target is an empty array" , async ( ) => {
0 commit comments