node package manager



Make dynamic tests that checks that corresponding components at least renders on your fixtures.


npm i cosmos-mocha --save-dev

Add CosmosTest.js to your mocha tests

import {generateTests} from 'cosmos-mocha';
generateTests(require('react/addons'), __dirname, <fixtures relativePath>, <components relativePath>);

you can skip generated test adding leading 'x' to fixture filename.

JSdom node test and karma-webpack tests

cosmos-mocha support jsdom node tests (jsdom requires io.js and will not work with Node.js 0.12 or below) or karma-webpack browser tests (see examples) jsdom runs in node (no browser) so they are faster but they ignore all webpack specific requires like require('style.less') if have these and want to use cosmos-mocha with css-modules for example you need to run it as karma-webpack example do.


Also try to run

npm run test

in example, and break some component or delete required prop from fixture.