Test failed: When the child pipeline faces an issue related to JavaScript out of memory or a Timeout Issue
When child pipeline face issue related to JavaScript out of memory or Timeout Issue
FATAL ERROR: Reached heap limit Allocation failed – JavaScript heap out of memory This error is cropping up in jobs running the unit tests for certain blocks where the test will fail with the above memory error. The exact cause is unknown but it seems to be consistent for the tests of certain blocks that will always fail. What is known is that it is producing the coverage report that causes the memory issue and not just running the tests themselves. Thankfully there is a simple fix which is to switch the coverage provider in Jest from the default Babel to V8. This provider is much more efficient and should give better error reports for any future failures. The way to make this switch is in the `package.json` of the block itself by adding the following anywhere within the `jest` section. “coverageProvider”: “v8” UPDATE (05/01/24): In certain cases this can lead to the coverage report giving 0 percent for all files and branches (this seems to be related to using the jsdom test environment for testing web files). If you see this issue please fix the `devDependencies` in the package.json of the failing block to the following versions: “@types/jest”: “26.0.24”, “babel-jest”: “26.6.3”, “jest”: “26.6.3”, “jest-cucumber”: “3.0.1”, “ts-jest”: “26.5.6”, And then also add this to the `resolutions`: “jest-environment-jsdom”: “26.6.2” These updates fix Jest and related libraries to version 26 and ensure that the jsdom library is version 16, which is the minimum version the v8 coverage provider needs to work properly with the jsdom test environment.