react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

Run only single test #262

Closed ZigaVukcevicDev closed 8 years ago

ZigaVukcevicDev commented 8 years ago

Hi,

thank you for the awesome pack.

Can you point me how to run only single test?

weblogixx commented 8 years ago

Hi @be-codified,

unfortunately this is not that easy in webpack based setups. Basically you have two options: Either run the whole tests (in best case using npm run test:watch mode) or you have to adjust the file test/loadtest.js to match your paths.

Here is a quick example:

// Edit file test/loadtest.js:
// Add support for all files in the test directory
// This is the original line, which will include all files that end with the suffix Test.js
// const testsContext = require.context('.', true, /(Test\.js$)/);

// Updated line, will only run tests located in test/components/subfolder that end with MyTestName.js
const testsContext = require.context('./components/subfolder', true, /(MyTestNameTest\.js$)/);

Hope this helps.

ZigaVukcevicDev commented 8 years ago

It helped, thank you.

ZigaVukcevicDev commented 8 years ago

@weblogixx I am noticing that consumed time is for raising up the server, not doing the test. Is there any way to leave the server running and then just run test?

weblogixx commented 8 years ago

Hi @be-codified,

you may just use npm run test:watch. In this mode, karma will stay active and rerun all tests if you change a file located in src/ or test/.

ZigaVukcevicDev commented 8 years ago

Oh, great. Thank you again.