exclude test.js file in create-react-app

Viewed 2329

I have used create-react-app to create an application.

I have my .test.js files next to the files they are testing:

so:

|
|_ Input.js
|_ Input.test.js

Do I need to add anything to .babelrc to stop the *.test.js files getting bundled with the development or production build.

I can't see anywhere in the source where they are being excluded.

1 Answers

You can exclude the test by changing the expression for the files included for build in webpack-config.js

/^(?!.*\.test\.js$).*\.js$/

This will load only '.js' files while leaving 'test.js' files

Related