When I run my jest tests, the amount of memory used per test increases over time. The issue wasn't apparent on my local machine; instead, I found this out when running my tests on CircleCI. I got the following error:
FAIL __tests__/pages/login.test.tsx
● Test suite failed to run
jest: failed to cache transform results in: /tmp/jest_2ne/jest-transform-cache-7bdebd1a0c578519274d14a78b89f87c-f8238a99880aac6151736010e575fab1/0b/symbols_0bf4cffb45cb261625f2f3fca21a4789.map
Failure message: ENOMEM: not enough memory, write
at writeFileSync (node_modules/write-file-atomic/index.js:215:10)
at writeCacheFile (node_modules/@jest/transform/build/ScriptTransformer.js:809:33)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:554:7)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:586:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:624:25)
How can I fix my jest configuration to prevent this?