-
Notifications
You must be signed in to change notification settings - Fork 460
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
TS, lerna monorepo and ts-jest@beta Error: Unable to compile TypeScript Module was resolved to 'index.tsx', but '--jsx' is not set. #699
Comments
[jest-config].globals.ts-jest.diagnostics.ignoreCodes
to ignore): /__tests__/iindex.test.tsx:3:20 - error TS6142: Module '../src/index' was resolved to 'index.tsx', but '--jsx' is not set.
Thanks a lot for reporting this. For beta it's advised to come over in slack to get some help ;-) |
Oh, and there is a minimal repo, thanks a lot! |
@budarin actually I'd love if you could come over in Slack to help me setup correctly your repo... I've not used lerna much more than once some months ago :-D |
Fixed in 3910f2c |
Just been battling this issue for nearly 24 hours. Followed the above repo structure and still had no luck! Seems to be something related to the TypeScript project references? Managed to fix by adding this to my const base = require("./jest.config.base.js");
module.exports = {
...base,
projects: ["<rootDir>/packages/*/jest.config.js"],
globals: {
"ts-jest": {
tsConfig: "packages/tsconfig.json" // Directly target the tsconfig shared across projects
}
}
}; Hope that's helpful for anyone else! |
@joe-bell Are you able to share anything more about how your repo is set up? Would love to see |
Sure, these are the two Jest configs in the root // jest.config.base.js
module.exports = {
rootDir: '../../',
preset: 'ts-jest',
testEnvironment: 'jsdom',
snapshotSerializers: ['jest-emotion'],
setupTestFrameworkScriptFile: './.config/jest/setup.ts',
}; // jest.config.js
const base = require('./jest.config.base.js');
module.exports = {
...base,
projects: ['<rootDir>/packages/*/jest.config.js'],
globals: {
'ts-jest': {
tsConfig: 'packages/tsconfig.json',
},
},
}; This is the The paths alias our package names to the appropriate directory. {
"compilerOptions": {
"strict": true,
"composite": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"esModuleInterop": true,
"target": "es5",
"module": "commonjs",
"jsx": "react",
"moduleResolution": "node",
"baseUrl": "../",
"paths": {
"@org-name/package-name-*": ["./packages/*/src"]
}
}
} |
Issue :
Trying to test React component is failing
Have read:
Troubles using it with TS3 and composite project
Guide to use Jest with Lerna
and set up my lerna typescript monorepo.
without importing React components - test is passed^ but when I try to import React componet I get the error:
although
build
command builts the componentExpected behavior :
pass tests without errors
Output from debug log :
Minimal repo :
https://github.com/budarin/ui-kit-bootstrap
The text was updated successfully, but these errors were encountered: