stub-class-unit-tests

0.2.0 • Public • Published

stub-class-unit-tests

npm Dependencies Build Status Coverage Status JavaScript Standard Style

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

Tim De Pauw

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i stub-class-unit-tests

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • timdp