Jest recommends use --detectOpenHandles but with --detectOpenHandles nothing special happen

Viewed 1470

I always get this message printed when I run my tests with jest --silent:

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

But when I run jest --silent --detectOpenHandles nothing special happens, no extra message, no warning, nothing. It just completes correctly.

I am using:

"jest": "^26.6.3",
"jest-extended": "^0.11.5",
"jest-preset-angular": "^8.3.2",
"ts-jest": "^26.4.4",
"ts-mockito": "^2.6.1",

and my config is:

const ignoredFiles = [
  '<rootDir>/src/test.ts',
  '<rootDir>/src/main.ts',
  '<rootDir>/src/jest-global.mocks.ts',
  '<rootDir>/src/polyfills.ts',
  '<rootDir>/src/test-helpers.ts',
  '<rootDir>/src/mocks',
  '<rootDir>/plugins/',
  '<rootDir>/coverage/',
  '<rootDir>/scripts/',
  '<rootDir>/android/',
  '<rootDir>/e2e/',
  '<rootDir>/ssd_hooks/',
  '<rootDir>/typings/',
  '<rootDir>/platforms/',
  '<rootDir>/plugins/',
  '<rootDir>/resources/',
  '<rootDir>/manual-plugins/'
];

module.exports = {
  preset: 'jest-preset-angular',
  setupFilesAfterEnv: ['<rootDir>/src/setupJest.ts'],
  transformIgnorePatterns: ['<rootDir>/node_modules/(?!@ionic|@saninn|@ngrx|@capacitor-community)'],
  coverageReporters: process.env.CI ? ['text'] : ['lcov'],
  testPathIgnorePatterns: ['/node_modules/', ...ignoredFiles],
  modulePathIgnorePatterns: ['<rootDir>/coverage/', '<rootDir>/plugins/'],
  collectCoverage: false,
  notify: true,
  coverageDirectory: './coverage',
  collectCoverageFrom: ['<rootDir>/src/**/*.ts', '!**/*.module.ts', '!**/*.enum.ts'],
  coveragePathIgnorePatterns: ['/node_modules/', 'package.json', ...ignoredFiles],
  globals: {
    'ts-jest': {
      tsconfig: '<rootDir>/src/tsconfig.spec.json',
      diagnostics: {
        ignoreCodes: [
          6138, // declared but never read
          6133, // declared but never used,
          2322 // object should just have known keys
        ]
      }
    }
  }
};

How can I find what is causing jest to show that warning?

0 Answers
Related