|
| 1 | +/** |
| 2 | + * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @flow |
| 8 | + */ |
| 9 | + |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +const path = require('path'); |
| 13 | +const runJest = require('../runJest'); |
| 14 | + |
| 15 | +const DIR = path.resolve(__dirname, '../no_tests_found-test'); |
| 16 | + |
| 17 | +describe('No tests are found', () => { |
| 18 | + test('fails the test suite in standard situation', () => { |
| 19 | + const result = runJest(DIR, ['--testPathPattern', '/non/existing/path/']); |
| 20 | + const status = result.status; |
| 21 | + const stdout = result.stdout.toString(); |
| 22 | + |
| 23 | + expect(stdout).toMatch('No tests found'); |
| 24 | + expect(status).toBe(1); |
| 25 | + }); |
| 26 | + |
| 27 | + test("doesn't fail the test suite if --passWithNoTests passed", () => { |
| 28 | + const result = runJest(DIR, [ |
| 29 | + '--testPathPattern', |
| 30 | + '/non/existing/path/', |
| 31 | + '--passWithNoTests', |
| 32 | + ]); |
| 33 | + const status = result.status; |
| 34 | + const stdout = result.stdout.toString(); |
| 35 | + |
| 36 | + expect(stdout).toMatch('No tests found'); |
| 37 | + expect(status).toBe(0); |
| 38 | + }); |
| 39 | + |
| 40 | + test("doesn't fail the test suite if using --lastCommit", () => { |
| 41 | + // Since there are no files in DIR no tests will be found |
| 42 | + const result = runJest(DIR, ['--lastCommit']); |
| 43 | + const status = result.status; |
| 44 | + const stdout = result.stdout.toString(); |
| 45 | + |
| 46 | + expect(stdout).toMatch('No tests found'); |
| 47 | + expect(status).toBe(0); |
| 48 | + }); |
| 49 | + |
| 50 | + test("doesn't fail the test suite if using --onlyChanged", () => { |
| 51 | + // Since there are no files in DIR no tests will be found |
| 52 | + const result = runJest(DIR, ['--onlyChanged']); |
| 53 | + const status = result.status; |
| 54 | + const stdout = result.stdout.toString(); |
| 55 | + |
| 56 | + expect(stdout).toMatch('No tests found'); |
| 57 | + expect(status).toBe(0); |
| 58 | + }); |
| 59 | + |
| 60 | + test("doesn't fail the test suite if using --findRelatedTests", () => { |
| 61 | + // Since there are no files in DIR no tests will be found |
| 62 | + const result = runJest(DIR, ['--findRelatedTests', '/non/existing/path']); |
| 63 | + const status = result.status; |
| 64 | + const stdout = result.stdout.toString(); |
| 65 | + |
| 66 | + expect(stdout).toMatch('No tests found'); |
| 67 | + expect(status).toBe(0); |
| 68 | + }); |
| 69 | +}); |
0 commit comments