I'm using [email protected] on Mac with this config
module.exports = {
name: '',
verbose: true,
reporters: [
'default', [
],
testRunner: 'jest-circus/runner',
setupFilesAfterEnv: [
'expect-puppeteer',
'<rootDir>/setup.js'
],
preset: 'jest-puppeteer',
testEnvironment: 'jest-environment-puppeteer',
globalSetup: '<rootDir>/global-setup.js',
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest'
},
transformIgnorePatterns: [
'/node_modules/(automation-framework)'
]
};
When I run my tests, 1st time I got no errors but then systematically I got this error :
TypeError: jest: failed to cache transform results in: /private/var/folders/cd/9gmr40cd7gvg_4bjdlzdcvtm0000gn/T/jest_dx/jest-transform-cache-test-xxx-663cd5096d102708621094a35b6499ca/6f/index_6f50b55f88b774b3246293b72bc76e53.map
Failure message: onExit is not a function
at writeFileSync (/Users/.../node_modules/write-file-atomic/index.js:177:31)
at writeCacheFile (/Users/.../node_modules/@jest/transform/build/ScriptTransformer.js:739:33)
at ScriptTransformer.transformSource (/Users/.../node_modules/@jest/transform/build/ScriptTransformer.js:493:7)
at revertHook.exts (/Users/.../node_modules/@jest/transform/build/ScriptTransformer.js:601:23)
at Module._compile (/Users/.../node_modules/pirates/lib/index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Object.newLoader [as .js] (/Users/.../node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)`
I've read some similar old issues but none gave a clear way to fix this.
Could someone help please?
Thanks.
Can you add jest --showConfig info maybe?
For a quick fix jest --clearCache before you run tests.
Running jest --clearCache will make the run much slower.
Here's the config
``json
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/private/var/folders/cd/9gmr40cd7gvg_4bjdlzdcvtm0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "$project",
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"extraGlobals": [],
"forceCoverageMatch": [],
"globalSetup": "$project/global-setup.js",
"globalTeardown": "$project/node_modules/jest-environment-puppeteer/teardown.js",
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": [],
"throwOnModuleCollision": false
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"ts",
"tsx",
"node"
],
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"name": "Assistant SAT",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "$project",
"roots": [
"$project"
],
"runner": "jest-runner",
"setupFiles": [],
"setupFilesAfterEnv": [
"$project/node_modules/expect-puppeteer/lib/index.js",
"$project/setup.js"
],
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "$project/node_modules/jest-environment-puppeteer/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "$project/node_modules/jest-circus/runner.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.[t|j]sx?$",
"$project/node_modules/babel-jest/build/index.js",
{}
]
],
"transformIgnorePatterns": [
"/node_modules/(^automation-framework)"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": [],
"coverageDirectory": "$project/coverage",
"coverageProvider": "babel",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"findRelatedTests": false,
"forceExit": false,
"globalSetup": "$project/global-setup.js",
"globalTeardown": "$project/node_modules/jest-environment-puppeteer/teardown.js",
"json": false,
"lastCommit": false,
"listTests": false,
"logHeapUsage": false,
"maxConcurrency": 5,
"maxWorkers": 3,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"onlyChanged": false,
"onlyFailures": false,
"passWithNoTests": false,
"projects": [],
"reporters": [
[
"default",
{}
],
[
"$project/node_modules/jest-junit/index.js",
{
"suiteName": "System Acceptance tests",
"outputDirectory": "<rootDir>/reports",
"outputName": "sat.xml",
"titleTemplate": "{title}",
"ancestorSeparator": " › "
}
]
],
"rootDir": "$project",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testSequencer": "$project/node_modules/@jest/test-sequencer/build/index.js",
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchAll": false,
"watchman": true
},
"version": "25.1.0"
}
I'm having the same issue today:
$ jest --showConfig
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/tmp/jest_rs",
"clearMocks": true,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/home/ubuntu/app",
"detectLeaks": false,
"detectOpenHandles": false,
"displayName": {
"color": "white",
"name": "unit"
},
"errorOnDeprecated": false,
"extraGlobals": [],
"forceCoverageMatch": [],
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": [],
"throwOnModuleCollision": false
},
"moduleDirectories": [
"src/testing/mocks",
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": [
[
"\\.(css|scss)$",
"identity-obj-proxy"
]
],
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"name": "1e428b1538bb91f4767879304f3df7eb",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/home/ubuntu/app",
"roots": [
"/home/ubuntu/app"
],
"runner": "jest-runner",
"setupFiles": [],
"setupFilesAfterEnv": [
"/home/ubuntu/app/src/testing/unit/setupTestFramework.js"
],
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/home/ubuntu/app/node_modules/jest-environment-jsdom/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"/home/ubuntu/app/src/**/*.unitTest.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/home/ubuntu/app/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"/src/.*\\.(gql|graphql)$",
"/home/ubuntu/app/node_modules/jest-transform-graphql/index.js",
{}
],
[
"/src/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/[.]storybook/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
]
],
"transformIgnorePatterns": [
"/home/ubuntu/app/node_modules/@babel"
],
"watchPathIgnorePatterns": []
},
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/tmp/jest_rs",
"clearMocks": true,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/home/ubuntu/app",
"detectLeaks": false,
"detectOpenHandles": false,
"displayName": {
"color": "white",
"name": "api"
},
"errorOnDeprecated": false,
"extraGlobals": [],
"forceCoverageMatch": [],
"globalSetup": "/home/ubuntu/app/src/testing/integration/globalSetup.js",
"globalTeardown": "/home/ubuntu/app/src/testing/integration/globalTeardown.js",
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": [],
"throwOnModuleCollision": false
},
"moduleDirectories": [
"src/testing/mocks",
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": [
[
"\\.(css|scss)$",
"identity-obj-proxy"
]
],
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"name": "c75cb6aa18bab4fd401ec7468e2d7b24",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/home/ubuntu/app",
"roots": [
"/home/ubuntu/app"
],
"runner": "jest-runner",
"setupFiles": [
"/home/ubuntu/app/src/testing/integration/targetRandomDatabase.js"
],
"setupFilesAfterEnv": [
"/home/ubuntu/app/src/testing/integration/setupTestFramework.js"
],
"skipFilter": false,
"snapshotSerializers": [
"/home/ubuntu/app/src/testing/normalizeIdSerializer.js"
],
"testEnvironment": "/home/ubuntu/app/node_modules/jest-environment-node/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"/home/ubuntu/app/src/**/*.intTest.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/home/ubuntu/app/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"/src/.*\\.(gql|graphql)$",
"/home/ubuntu/app/node_modules/jest-transform-graphql/index.js",
{}
],
[
"/src/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/[.]storybook/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
]
],
"transformIgnorePatterns": [
"/home/ubuntu/app/node_modules/@babel"
],
"watchPathIgnorePatterns": []
},
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/tmp/jest_rs",
"clearMocks": true,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/home/ubuntu/app",
"detectLeaks": false,
"detectOpenHandles": false,
"displayName": {
"color": "white",
"name": "browser"
},
"errorOnDeprecated": false,
"extraGlobals": [],
"forceCoverageMatch": [],
"globalSetup": "/home/ubuntu/app/src/testing/e2e/globalE2eSetup.js",
"globalTeardown": "/home/ubuntu/app/src/testing/e2e/globalE2eTeardown.js",
"globals": {},
"haste": {
"computeSha1": false,
"providesModuleNodeModules": [],
"throwOnModuleCollision": false
},
"moduleDirectories": [
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": [
[
"\\.(css|scss)$",
"identity-obj-proxy"
],
[
"analyticsjs-bundle.js$",
"identity-obj-proxy"
]
],
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"name": "71baf254b9c44602400a2350f2903e6a",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/home/ubuntu/app",
"roots": [
"/home/ubuntu/app"
],
"runner": "jest-runner",
"setupFiles": [
"/home/ubuntu/app/src/testing/integration/targetRandomDatabase.js"
],
"setupFilesAfterEnv": [
"/home/ubuntu/app/src/testing/e2e/setupE2eTestFramework.js"
],
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/home/ubuntu/app/src/testing/e2e/environment.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"/home/ubuntu/app/src/**/*.e2eTest.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/home/ubuntu/app/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"/src/.*\\.(gql|graphql)$",
"/home/ubuntu/app/node_modules/jest-transform-graphql/index.js",
{}
],
[
"/src/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/[.]storybook/.*[.][jt]sx?$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
],
[
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$",
"/home/ubuntu/app/node_modules/babel-jest/build/index.js",
{}
]
],
"transformIgnorePatterns": [
"/home/ubuntu/app/node_modules/@babel"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": [],
"coverageDirectory": "/home/ubuntu/app/coverage",
"coverageProvider": "babel",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"findRelatedTests": false,
"forceExit": false,
"json": false,
"lastCommit": false,
"listTests": false,
"logHeapUsage": false,
"maxConcurrency": 5,
"maxWorkers": 5,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"onlyChanged": false,
"onlyFailures": false,
"passWithNoTests": false,
"projects": [
{
"clearMocks": true,
"moduleDirectories": [
"src/testing/mocks",
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy"
},
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"transform": {
"/src/.*\\.(gql|graphql)$": "jest-transform-graphql",
"/src/.*[.][jt]sx?$": "babel-jest",
"/[.]storybook/.*[.][jt]sx?$": "babel-jest",
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$": "babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/@babel"
],
"displayName": "unit",
"setupFilesAfterEnv": [
"<rootDir>/src/testing/unit/setupTestFramework.js"
],
"testMatch": [
"<rootDir>/src/**/*.unitTest.[jt]s?(x)"
],
"rootDir": "/home/ubuntu/app"
},
{
"clearMocks": true,
"moduleDirectories": [
"src/testing/mocks",
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy"
},
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"transform": {
"/src/.*\\.(gql|graphql)$": "jest-transform-graphql",
"/src/.*[.][jt]sx?$": "babel-jest",
"/[.]storybook/.*[.][jt]sx?$": "babel-jest",
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$": "babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/@babel"
],
"displayName": "api",
"globalSetup": "<rootDir>/src/testing/integration/globalSetup.js",
"globalTeardown": "<rootDir>/src/testing/integration/globalTeardown.js",
"setupFiles": [
"<rootDir>/src/testing/integration/targetRandomDatabase.js"
],
"setupFilesAfterEnv": [
"<rootDir>/src/testing/integration/setupTestFramework.js"
],
"snapshotSerializers": [
"./src/testing/normalizeIdSerializer.js"
],
"testEnvironment": "node",
"testMatch": [
"<rootDir>/src/**/*.intTest.[jt]s?(x)"
],
"rootDir": "/home/ubuntu/app"
},
{
"clearMocks": true,
"moduleDirectories": [
"src",
"node_modules"
],
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx",
"json",
"node"
],
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy",
"analyticsjs-bundle.js$": "identity-obj-proxy"
},
"modulePathIgnorePatterns": [
"npm-cache",
".npm"
],
"transform": {
"/src/.*\\.(gql|graphql)$": "jest-transform-graphql",
"/src/.*[.][jt]sx?$": "babel-jest",
"/[.]storybook/.*[.][jt]sx?$": "babel-jest",
"/home/ubuntu/app/node_modules/@ctrlpanel/pbkdf2/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-digest-sync/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/crypto-random-hex/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/encode-utf8/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/react-popover/.*[.]js$": "babel-jest",
"/home/ubuntu/app/node_modules/secure-remote-password/.*[.]js$": "babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/@babel"
],
"displayName": "browser",
"globalSetup": "<rootDir>/src/testing/e2e/globalE2eSetup.js",
"globalTeardown": "<rootDir>/src/testing/e2e/globalE2eTeardown.js",
"setupFiles": [
"<rootDir>/src/testing/integration/targetRandomDatabase.js"
],
"setupFilesAfterEnv": [
"<rootDir>/src/testing/e2e/setupE2eTestFramework.js"
],
"testEnvironment": "<rootDir>/src/testing/e2e/environment.js",
"testMatch": [
"<rootDir>/src/**/*.e2eTest.[jt]s?(x)"
],
"rootDir": "/home/ubuntu/app"
}
],
"rootDir": "/home/ubuntu/app",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testSequencer": "/home/ubuntu/app/node_modules/@jest/test-sequencer/build/index.js",
"updateSnapshot": "new",
"useStderr": false,
"watch": false,
"watchAll": false,
"watchman": true
},
"version": "25.1.0"
}
$ grep jest package.json
"@types/jest": "24.9.0",
"@types/jest-diff": "20.0.1",
"babel-jest": "25.1.0",
"eslint-plugin-jest": "23.8.1",
"jest": "25.1.0",
"jest-chain": "1.1.5",
"jest-diff": "25.1.0",
"jest-extended": "0.11.4",
"jest-junit": "10.0.0",
"jest-styled-components": "6.3.1",
"jest-transform-graphql": "2.1.0",
"ts-jest": "25.2.1",
$
Had someone solve this problem?
For me it just seemed to go away on its own after a while. Although telling jest to clear the cache didn't seem to fix it, something eventually cleared the problem away. Very strange, there must be some file that's causing the issue but isn't deleted by clearing the jest cache. Maybe something in the babel cache?
Now it is happening again today. I wonder if it's some kind of module load order issue or race condition, based on the error it seems like the package used to do some action on process exit is not loading properly.
I'm facing this issue too. From time to time, it appears and I fix it by reinstalling all node_modules. I don't know why to be honest, but --clearCache option doesn't solve the issue.
For this to be actionable we'd need a reproduction. I've personally never gotten this error (as far as I'm aware), so cannot even begin to debug it
This is only happening when you're using the transform option of jest
``javascript
"transform": [
[
"^.+\\.[t|j]sx?$",
"$project/node_modules/babel-jest/build/index.js",
{}
]
],
"transformIgnorePatterns": [
"/node_modules/(^automation-framework)"
],
I tried this to my jest config and it seems to fix it:
transformIgnorePatterns: [
'<rootDir>/node_modules/@babel',
'<rootDir>/node_modules/@jest',
],
I guess jest is transforming itself somehow and this is causing the issue.
with the update [email protected], I got the following error
(node:26044) UnhandledPromiseRejectionWarning: TypeError: jest: failed to cache transform results in: /Users/Projects/system_acceptance_tests/.cache/jest-transform-cache-Assistant-SAT-afca7609b727bae58e6d966e4f38887d/1b/index_1bd26eb79e9d5f8a74d76de47d84899e.map
Failure message: onExit is not a function
at writeFileSync (/Users/Projects/system_acceptance_tests/node_modules/write-file-atomic/index.js:201:31)
at writeCacheFile (/Users/Projects/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:791:33)
at ScriptTransformer.transformSource (/Users/Projects/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:536:7)
at revertHook.exts (/Users/Projects/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:655:18)
at Module._compile (/Users/Projects/system_acceptance_tests/node_modules/pirates/lib/index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Object.newLoader [as .js] (/Users/Projects/system_acceptance_tests/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
(node:26044) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:26044) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I upgraded the node to v10.21.0, and it looks work well.
I upgraded the node to v10.21.0, and it looks work well.
I'm using Node v12.18.1 and it's still happening to me.
I managed to fix this by preventing babel transform of signal-exit. This package, used by a bunch of dependencies of jest itself, has a default function export which apparently gets mangled by babel into no longer being a function. This is why the error is "onExit is not a function" - onExit is the variable that require('signal-exit') is assigned to in write-file-atomic.
Combined with @dobesv 's ignores for jest and babel themselves:
transformIgnorePatterns: [
'<rootDir>/node_modules/@babel',
'<rootDir>/node_modules/@jest',
'signal-exit',
],
Thanks a lot @ascott18 for your suggestions, that issue is fixed, but now I'm having the following
shell
Failure message: isTypedArray is not a function
at writeFileSync (/Projects/service/system_acceptance_tests/node_modules/write-file-atomic/index.js:209:9)
at writeCacheFile (/Projects/service/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:791:33)
at ScriptTransformer.transformSource (/Projects/service/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:536:7)
at revertHook.exts (/Projects/service/system_acceptance_tests/node_modules/@jest/transform/build/ScriptTransformer.js:655:18)
at Module._compile (/Projects/service/system_acceptance_tests/node_modules/pirates/lib/index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.newLoader [as .js] (/Projects/service/system_acceptance_tests/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:791:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
I finally managhed to fix this long lasting issue
here's the config that did the job
transformIgnorePatterns: [
'<rootDir>/node_modules/@babel',
'<rootDir>/node_modules/@jest',
'<rootDir>/node_modules/lodash',
'signal-exit',
'is-typedarray'
],
Big kudos to @ascott18 for opening my eyes on the source of this damn issue 😄 👏
Most helpful comment
I managed to fix this by preventing babel transform of signal-exit. This package, used by a bunch of dependencies of jest itself, has a default function export which apparently gets mangled by babel into no longer being a function. This is why the error is "onExit is not a function" -
onExitis the variable thatrequire('signal-exit')is assigned to inwrite-file-atomic.Combined with @dobesv 's ignores for jest and babel themselves: