Test .js and .jsx extensions with mocha

Out the box, mocha only runs files with a .js extension.

If you want to run files with a .jsx extension, you can use regex:

mocha 'test/**/*.{js,jsx}'

You probably need to compile JSX. If you’re using babel, install babel-register:

npm i -D babel-register

Tell mocha to compile .js and .jsx files with babel-register and the mocha require option:

mocha 'test/**/*.{js,jsx}' --require babel-register

Your full command will look something like this:

mocha 'test/**/*.{js,jsx}' --recursive --require babel-register