File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed
integration_tests/__tests__ Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ test('config as JSON', () => {
21
21
] ) ;
22
22
const stdout = result . stdout . toString ( ) ;
23
23
24
- expect ( result . status ) . toBe ( 0 ) ;
24
+ expect ( result . status ) . toBe ( 1 ) ;
25
25
expect ( stdout ) . toMatch ( 'No tests found' ) ;
26
26
} ) ;
27
27
Original file line number Diff line number Diff line change @@ -13,26 +13,26 @@ const runJest = require('../runJest');
13
13
14
14
const DIR = path . resolve ( __dirname , '../failWithNoTests' ) ;
15
15
16
- describe ( 'jest --failWithNoTests ' , ( ) => {
17
- test ( "doesn't fail the test suite if no files are found" , ( ) => {
16
+ describe ( 'jest --passWithNoTests ' , ( ) => {
17
+ test ( 'fails the test suite if no files are found' , ( ) => {
18
18
const result = runJest ( DIR , [ '--testPathPattern' , '/non/existing/path/' ] ) ;
19
19
const status = result . status ;
20
20
const stdout = result . stdout . toString ( ) ;
21
21
22
22
expect ( stdout ) . toMatch ( 'No tests found' ) ;
23
- expect ( status ) . toBe ( 0 ) ;
23
+ expect ( status ) . toBe ( 1 ) ;
24
24
} ) ;
25
25
26
- test ( 'fails the test suite if no files are found' , ( ) => {
26
+ test ( "doesn't fail the test suite if no files are found" , ( ) => {
27
27
const result = runJest ( DIR , [
28
28
'--testPathPattern' ,
29
29
'/non/existing/path/' ,
30
- '--failWithNoTests ' ,
30
+ '--passWithNoTests ' ,
31
31
] ) ;
32
32
const status = result . status ;
33
33
const stdout = result . stdout . toString ( ) ;
34
34
35
35
expect ( stdout ) . toMatch ( 'No tests found' ) ;
36
- expect ( status ) . toBe ( 1 ) ;
36
+ expect ( status ) . toBe ( 0 ) ;
37
37
} ) ;
38
38
} ) ;
Original file line number Diff line number Diff line change @@ -169,11 +169,6 @@ const options = {
169
169
description : 'Use this flag to show full diffs instead of a patch.' ,
170
170
type : 'boolean' ,
171
171
} ,
172
- failWithNoTests : {
173
- default : false ,
174
- description : 'Will fail if no tests are found (for example while using `--testPathPattern`.)' ,
175
- type : 'boolean' ,
176
- } ,
177
172
findRelatedTests : {
178
173
default : undefined ,
179
174
description : 'Find related tests for a list of source files that were ' +
@@ -290,6 +285,11 @@ const options = {
290
285
'also specified.' ,
291
286
type : 'string' ,
292
287
} ,
288
+ passWithNoTests : {
289
+ default : false ,
290
+ description : 'Will not fail if no tests are found (for example while using `--testPathPattern`.)' ,
291
+ type : 'boolean' ,
292
+ } ,
293
293
preset : {
294
294
description : "A preset that is used as a base for Jest's configuration." ,
295
295
type : 'string' ,
Original file line number Diff line number Diff line change @@ -182,12 +182,12 @@ const runJest = async (
182
182
if ( ! allTests . length ) {
183
183
const noTestsFoundMessage = getNoTestsFoundMessage ( testRunData , pattern ) ;
184
184
185
- if ( argv . failWithNoTests ) {
185
+ if ( argv . passWithNoTests ) {
186
+ new Console ( pipe , pipe ) . log ( noTestsFoundMessage ) ;
187
+ } else {
186
188
new Console ( pipe , pipe ) . error ( noTestsFoundMessage ) ;
187
189
188
190
process . exit ( 1 ) ;
189
- } else {
190
- new Console ( pipe , pipe ) . log ( noTestsFoundMessage ) ;
191
191
}
192
192
} else if (
193
193
allTests . length === 1 &&
You can’t perform that action at this time.
0 commit comments