''Async' tests runs forever jest

I have a problem on new environment with async tests with jest

    "jest": "^27.4.6",
    "babel-jest": "^27.4.6",
    "react": "17.0.1",
"jest": {
    "preset": "react-native",
    "setupFiles": [
      "<rootDir>/jest/setup.js"
    ],
    "setupFilesAfterEnv": [
      "@testing-library/jest-native/extend-expect"
    ],
    "transformIgnorePatterns": [
      "node_modules/(?!(@react-native|react-native|react-native-android-location-enabler|react-native-config|react-native-actionsheet|@sentry/react-native|reselect|redux-persist)/)"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  },

the case is that event trying to run the simplest test ever, jest never actually execute it:

const giveMeAfterSec = () => {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve('wow');
        }, 1000);
    });
};

describe('dummy', () => {
    test('async test', async () => {
        const result = await giveMeAfterSec();

        expect(result).toBe('wow');
    });
});

and trying to run it, I see never ending

RUNS src/__tests__/dummy.test.tsx

Every test without async await runs properly



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source