Reputation: 169
When trying to run my tests in a dual client / server repo, I'm getting the following error that I can't seem to get past.
> jest --debug
{
"configs": [
{
"automock": false,
"cache": true,
"cacheDirectory": "/private/var/folders/ff/6qxxwcg50zq0mr4xzbfbyqyh0000gp/T/jest_dy",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/"
],
"cwd": "/Users/jsavino/Development/mercury-mail-admin",
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"extraGlobals": [],
"forceCoverageMatch": [],
"globals": {},
"haste": {
"throwOnModuleCollision": true
},
"injectGlobals": true,
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"js",
"json",
"jsx",
"ts",
"tsx",
"node"
],
"moduleNameMapper": [],
"modulePathIgnorePatterns": [],
"name": "d373cb7a79c783e70b01f44f2dfaf64c",
"prettierPath": "prettier",
"resetMocks": false,
"resetModules": false,
"restoreMocks": false,
"rootDir": "/Users/jsavino/Development/mercury-mail-admin",
"roots": [
"/Users/jsavino/Development/mercury-mail-admin/server"
],
"runner": "jest-runner",
"setupFiles": [],
"setupFilesAfterEnv": [],
"skipFilter": false,
"slowTestThreshold": 5,
"snapshotSerializers": [],
"testEnvironment": "/Users/jsavino/Development/mercury-mail-admin/node_modules/jest-environment-jsdom/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": null,
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": [],
"testRunner": "/Users/jsavino/Development/mercury-mail-admin/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.(ts|tsx)$",
"/Users/jsavino/Development/mercury-mail-admin/node_modules/ts-jest/dist/index.js",
{}
],
[
"^.+\\.tsx?$",
"/Users/jsavino/Development/mercury-mail-admin/node_modules/ts-jest/dist/index.js",
{}
]
],
"transformIgnorePatterns": [
"/node_modules/",
"\\.pnp\\.[^\\/]+$"
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": [],
"coverageDirectory": "/Users/jsavino/Development/mercury-mail-admin/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": 15,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "failure-change",
"onlyChanged": false,
"onlyFailures": false,
"passWithNoTests": false,
"projects": [],
"rootDir": "/Users/jsavino/Development/mercury-mail-admin",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testSequencer": "/Users/jsavino/Development/mercury-mail-admin/node_modules/@jest/test-sequencer/build/index.js",
"updateSnapshot": "new",
"useStderr": false,
"watch": false,
"watchAll": false,
"watchman": true
},
"version": "26.6.3"
}
TypeError: _jestHasteMap(...).default is not a constructor
at Function.createHasteMap (/Users/jsavino/Development/mercury-mail-admin/node_modules/jest-runtime/build/index.js:475:12)
at /Users/jsavino/Development/mercury-mail-admin/node_modules/@jest/core/build/cli/index.js:327:55
at Array.map (<anonymous>)
at buildContextsAndHasteMaps (/Users/jsavino/Development/mercury-mail-admin/node_modules/@jest/core/build/cli/index.js:324:13)
at _run10000 (/Users/jsavino/Development/mercury-mail-admin/node_modules/@jest/core/build/cli/index.js:401:47)
at runCLI (/Users/jsavino/Development/mercury-mail-admin/node_modules/@jest/core/build/cli/index.js:271:9)
at async Object.run (/Users/jsavino/Development/mercury-mail-admin/node_modules/jest/node_modules/jest-cli/build/cli/index.js:163:37)
My repo is organized as such:
package.json
jest.config.js
tsconfig.json
server/ <- Location where the tests files are being run. A pretty basic express app written in typescript
client/ <- The output of CRA, also in typescript. Jest tests in this directory run fine
My jest.config.js
module.exports = {
roots: ["<rootDir>/server"],
testMatch: null,
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
testRegex: [],
preset: "ts-jest",
};
And my tsconfig.json
:
{
"compilerOptions": {
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./build", /* Redirect output structure to the directory. */
"rootDir": "./server", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"resolveJsonModule": true,
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"./server"
],
"exclude": [
"client"
]
}
The app itself works fine both when compiled / run directly.
My dependencies:
"dependencies": {
"@kubernetes/client-node": "^0.14.3",
"body-parser": "^1.18.3",
"connect": "^3.7.0",
"cors": "^2.8.5",
"cronstrue": "^1.112.0",
"express": "^4.17.1",
"express-openapi-validator": "^4.12.7",
"swagger-express-router": "^1.0.0",
"swagger-routes-express": "^3.3.0",
"swagger-ui-express": "^4.1.6",
"ts-jest": "^26.5.5",
"uuid": "^8.3.2",
"validator": "^13.5.2",
"yamljs": "^0.3.0"
},
"devDependencies": {
"@babel/core": "^7.13.16",
"@babel/preset-env": "^7.13.15",
"@babel/preset-typescript": "^7.13.0",
"@types/cors": "^2.8.10",
"@types/express": "^4.17.11",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.40",
"@types/swagger-ui-express": "^4.1.2",
"@types/uuid": "^8.3.0",
"@types/validator": "^13.1.3",
"@types/yamljs": "^0.2.31",
"babel-jest": "^26.6.3",
"concurrently": "^6.0.2",
"jest": "^26.6.3",
"nodemon": "^2.0.7",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
}
I've been stumped on this one for a few days, so any nudges in the right direction would be much appreciated. Thank you!
Upvotes: 3
Views: 4575
Reputation: 169
Turns out this was a weird package-lock.json
issue. Wiping away node_modules/
and package-lock.json
for a fresh install fixed thing. Not super sure how things got out of wack, but they did somehow.
Upvotes: 1