@lizzie
To run Mocha tests written in TypeScript and JSX (tsx), you need to make sure that you have configured Mocha to work with TypeScript and JSX.
Here are the steps to run Mocha tests written in tsx:
1
|
npm install --save-dev mocha ts-node @babel/register @babel/preset-env @babel/preset-react |
1 2 3 4 5 6 |
{ "presets": [ "@babel/preset-env", "@babel/preset-react" ] } |
1 2 3 |
--require ts-node/register --require @babel/register --require ignore-styles |
1
|
mocha --opts mocha.opts testfile.tsx |
This will run your Mocha tests written in tsx using ts-node to compile TypeScript code and @babel/register to transpile JSX syntax.
Make sure to adjust the file paths and configurations according to your project structure and requirements.