generate-unit-test
v0.1.2
Published
Generate unit test for Mocha, Chai and sinon from component source file
Downloads
2
Readme
generate-unit-test
Pass file to generate-unit-test and it will generate basic unit test boilerplate: checkout: from Headline.react.js it creates test directory and generate __test__/Headline.js
Install
$ npm install --save generate-unit-test
Gulp Usage
import generateUnitTest from 'generate-unit-test';
gulp.task('generate-test', (done) => {
if (yargs.argv.file)
// test/mochaTestHelper - is relative path to project which point to mocha test helper
generateUnitTest(`${__dirname}/${yargs.argv.file}`, __dirname, 'test/mochaTestHelper')
else
console.error('Please provide component file by --file some/file')
})
# => gulp generate-test --file src/client/components/Xyz.js
CLI Usage
generate-unit-test src/client/components/Xyz.js src/client/components/Zaz.js
mochaTestHelper
import chai, {assert, expect} from 'chai';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
chai.should();
chai.use(sinonChai);
export {
assert,
chai,
expect,
React,
sinon,
sinonChai,
TestUtils
};
License
MIT © Ondrej Bartas
Boilerplated from (https://github.com/este/module)