jest-runner-tsc icon indicating copy to clipboard operation
jest-runner-tsc copied to clipboard

How to support JSX?

Open aralroca opened this issue 4 years ago • 0 comments

package.json

{
 "scripts": {
    "test": "jest ./tests",
    "test:ts": "jest -c jest.tsc.config.js"
  },
 "jest-runner-tsc": {
    "tsconfigPath": "./tsconfig.json"
  }
}

jest: 27.4.7 jest-runner-tsc: 1.6.0

jest.tsc.config.js

module.exports = {
  runner: 'jest-runner-tsc',
  displayName: 'tsc',
  moduleFileExtensions: ['js', 'jsx','ts', 'tsx'],
  testMatch: ['<rootDir>/tests/*.tsx'],
};

tsconfig.json

{
  "compileOnSave": false,
  "module": "ESNext",
  "target": "ESNext",
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "declaration": true,
      "moduleResolution": "node",
      "esModuleInterop": true
    },
  "include": ["package/*.ts", "test/*.tsx"]
}

Running yarn test is working fine!!!

However running yarn test:ts an error is fired: Cannot use JSX unless the '--jsx' flag is provided.. When do I need to add this --jsx flag?

image

Thanks

aralroca avatar Jan 13 '22 18:01 aralroca