stub-class-unit-tests
v0.2.0
Published
Stubs unit tests for ES2015 classes.
Downloads
3
Readme
stub-class-unit-tests
Stubs unit tests for ES2015 classes. Uses Mocha + Chai.
This is very much a work in progress.
Usage
import stubClassUnitTests from 'stub-class-unit-tests'
import fs from 'fs'
class MyClass {
constructor () {
this._foo = 0
}
get foo () {
return this._foo
}
set foo (value) {
this._foo = value
}
add (num) {
this._foo += num
}
}
const jsCode = stubClassUnitTests(MyClass)
fs.writeFileSync('test.js', jsCode, 'utf8')
Options
className
Override the class name. Defaults to constructor.name
.
importPath
Path to the module that exports the class, relative to where you're going to
save the test source code. Used to generate an import
statement.
importType
Either 'default'
(default export, the default) or 'named'
(named export).
Determines how the class will be imported from importPath
.
Author
License
MIT