I'm trying to run mocha testing with React-Native and my app is built in Typescript. It's an Expo app in a yarn workspace (if that matters).
When I run the tests with mocha -r ts-node/register --extensions ts,tsx './src/**/*.spec.{ts,tsx}'"
I get the error unexpected token <
I've tried adding in babel with mocha -r babel-register -r ts-node/register './src/**/*.spec.{js,jsx,ts,tsx}'
And this returns a ton of typescript errors, which don't show up when I compile my typescript code, so I'm thinking that may be a red herring.
My tsconfig
is
{"compilerOptions": {"allowSyntheticDefaultImports": true,"lib": ["dom", "esnext"],"moduleResolution": "node","module": "commonjs","noEmit": false,"skipLibCheck": true,"resolveJsonModule": true,"noImplicitReturns": true,"noFallthroughCasesInSwitch": true,"noImplicitAny": true,"strictNullChecks": true"jsx": "preserve","noEmit": true },"include": ["./**/*.*"] }
I'm thinking this is that the JSX isn't being compiled. The spec file is index.spec.tsx
so that isn't the issue.