Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError with create-react-app, react-app-rewire-ts-jest and ts-jest 23.1.3 #682

Closed
abenhamdine opened this issue Aug 18, 2018 · 6 comments

Comments

@abenhamdine
Copy link

abenhamdine commented Aug 18, 2018

Issue :

With last version 23.1.3, I run into the following error on every test:

 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
      
      at assertPath (path.js:39:11)
      at Object.relative (path.js:1172:5)
      at Object.getCacheKey (node_modules/ts-jest/dist/utils/get-cache-key.js:15:16)

If I reinstall version 23.0.1, errors go away and the tests are passing normally.

I tried to install jest-cli last version 23.5.0 but I ran into another issue :

TypeError: environment.teardown is not a function
  at node_modules/jest-runner/build/run_test.js:188:25

which is probably the same error described in jestjs/jest#6269
since I also use create-react-app

Environment

I use creat-react-app without ejecting (thanks to react-app-rewired).

Packages versions:

"ts-jest" : "23.1.3",
"jest-cli": "20.0.4",
"react-app-rewire-ts-jest": "1.0.17",
"react-scripts": "1.1.4",

No jest or babel configuration except those included in react-scripts (create-react-app)

tsconfig :

{
	"compilerOptions": {
		"allowSyntheticDefaultImports": true,
		"baseUrl": ".",
		"paths": {
			"*": [
				"src/*"
			]
		},
		"outDir": "build/dist",
		"module": "esnext",
		"target": "es5",
		"lib": [
			"es6",
			"dom"
		],
		"sourceMap": true,
		"allowJs": true,
		"jsx": "preserve",
		"moduleResolution": "node",
		"forceConsistentCasingInFileNames": true,
		"noImplicitReturns": false,
		"noImplicitThis": false,
		"noImplicitAny": false,
		"strictNullChecks": true,
		"suppressImplicitAnyIndexErrors": true,
		"noUnusedLocals": true
	},
	"exclude": [
		"config-overrides.js",
		"node_modules",
		"client/build",
		"server/build",
		"dist/",
		"scripts",
		"acceptance-tests",
		"webpack",
		"jest",
		"src/setupTests.ts"
	]
}

Expected behavior :

No errors.

Output from debug log :

# content of debug.txt :

Minimal repo :

to come soon

@huafu
Copy link
Collaborator

huafu commented Aug 18, 2018

Hi @abenhamdine, thanks for reporting.
Can you provide a minimal repo to reproduce the issue?

@abenhamdine
Copy link
Author

I will try, but I lack time to do it these days.

@huafu
Copy link
Collaborator

huafu commented Aug 18, 2018

Well, at least provide the package dependencies with versions, as well as babelrc (if used), jest config and tsconfig.
ELse we cannot investigate much the issue.

Also to note even tho you might know it: try to get on latest jest, ts-jest and typescript. Remove node_modules and re-run npm install (or yarn), run jest --clearCache, ...

@abenhamdine
Copy link
Author

I edited my first post to add packages versions and details about environment.
I'm sorry, I don't have enough time to add a minimal repro right now (I'm still on my vacation trip) but I will devote some time add it late august.

@huafu
Copy link
Collaborator

huafu commented Aug 18, 2018

Thanks, with what you write down I can already (quickly) tell you:

  • Your jest-cli is very old, I believe latest version is 23.x.
  • in compiler options, try to remove allowSyntheticDefaultImports and replace it with esModuleInterop set to true
  • ensure you have TypeScript >= 2.7 in deps

UPDATE: the path error is FOR SURE about old jest version, so I am closing this right now.
We are following jest major version with our versions, so if you want to use ts-jest version X.?.?, you'll need to have jest X.?.?

If you think I am wrong somewhere, feel free to re-open of course.

@huafu huafu closed this as completed Aug 18, 2018
@abenhamdine
Copy link
Author

Ok, thx for your time and the useful feedbacks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants