Stubs unit tests for ES2015 classes. Uses Mocha + Chai.
This is very much a work in progress.
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')
Override the class name. Defaults to constructor.name
.
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.
Either 'default'
(default export, the default) or 'named'
(named export).
Determines how the class will be imported from importPath
.
MIT