|
| 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 | +'use strict'; |
| 10 | + |
| 11 | +const runJest = require('../runJest'); |
| 12 | + |
| 13 | +try { |
| 14 | + // $FlowFixMe: Node core |
| 15 | + require('async_hooks'); |
| 16 | +} catch (e) { |
| 17 | + if (e.code === 'MODULE_NOT_FOUND') { |
| 18 | + // eslint-disable-next-line jest/no-focused-tests |
| 19 | + fit('skip test for unsupported nodes', () => { |
| 20 | + console.warn('Skipping test for node ' + process.version); |
| 21 | + }); |
| 22 | + } else { |
| 23 | + throw e; |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +function getTextAfterTest(stderr) { |
| 28 | + return stderr.split('Ran all test suites.')[1].trim(); |
| 29 | +} |
| 30 | + |
| 31 | +it('prints message about flag on slow tests', async () => { |
| 32 | + const {stderr} = await runJest.until( |
| 33 | + 'detect-open-handles', |
| 34 | + [], |
| 35 | + 'Jest did not exit one second after the test run has completed.', |
| 36 | + ); |
| 37 | + const textAfterTest = getTextAfterTest(stderr); |
| 38 | + |
| 39 | + expect(textAfterTest).toMatchSnapshot(); |
| 40 | +}); |
| 41 | + |
| 42 | +it('prints message about flag on forceExit', async () => { |
| 43 | + const {stderr} = await runJest.until( |
| 44 | + 'detect-open-handles', |
| 45 | + ['--forceExit'], |
| 46 | + 'Force exiting Jest', |
| 47 | + ); |
| 48 | + const textAfterTest = getTextAfterTest(stderr); |
| 49 | + |
| 50 | + expect(textAfterTest).toMatchSnapshot(); |
| 51 | +}); |
| 52 | + |
| 53 | +it('prints out info about open handlers', async () => { |
| 54 | + const {stderr} = await runJest.until( |
| 55 | + 'detect-open-handles', |
| 56 | + ['--detectOpenHandles'], |
| 57 | + 'Jest has detected', |
| 58 | + ); |
| 59 | + const textAfterTest = getTextAfterTest(stderr); |
| 60 | + |
| 61 | + expect(textAfterTest).toMatchSnapshot(); |
| 62 | +}); |
0 commit comments