mocha-mix
started as a out-of-box unit testing tool for ReactJS. It focuses more toward providing interface for creating easy mocking and testing scope isolation
.
npm install --save-dev mocha-mix
mocha-mix-jsdom
: Exposeswindow
anddocument
to global scope. Useful to test React usingmocha
.mocha-mix-jsdom-3
:mocha-mix-jsdom
using[email protected]
. Useful for those who uses [email protected] or lower.mocha-mix-react
: Provides helpful default mock generator for React unit testing.mocha-mix-react.0.13
:mocha-mix-react
using[email protected]
mocha-mix-mockery
: Usesmockery
as mock engine.mocha-mix-jest
: Uses jest as mock engine. (In progress)mocha-mix-jasmine
: Provides test hooks getter for jasmine. (In progress)
Returns a new Mixer with given recipe object.
mix(recipe: Recipe): Mixer
Takes given functional argument as a plugin.
use(plugin: Function): void
Replaces a testHookGetter with given getter Function.
setTestHooksGetter(getter: Function): void
Replaces a defaultMockGenerator with given generator function
setDefaultMockGenerator(generator: Function or MockGenerator): void
Registers given function as beforeAll hook
before(hook: Function or MixHook): void
Registers given function as beforeAll hook
before(hook: Function or MixHook): void
Registers given function as beforeEach hook
beforeEach(hook: Function or MixHook): void
Registers given function as afterEach hook
afterEach(hook: Function or MixHook): void
Registers given function as after hook
after(hook: Function or MixHook): void
clears all registered named hooks with given hookName
clearHook(hookName: string): void
clears all registered hooks
clearAllHooks(void): void
Returns a function which wraps the given function. In testing runtime, MockDescription instance will be passed down to the generator for further customization.
MockGenerator(generator: Function): GeneratorWrapper
Returns a function which wraps the given test hook function.
MixHook(hook: Function): Wrapper
Returns a function if the given plugin function is valid.
MixPlugin(plugin: Function): Function
Returns mixer instance.
Mixer(MixRecipe): Mixer
Returns a default module. Follows ES6 Module standard.
import(void): Any
Returns a module using commonJS pattern.
require(void): Any
Returns a module as wildcard import. Follows ES6 Module standard.
Registers mock reference so that in can be referenced in a test scope.
registerMock(name: String, mock: Any): void
Clears a mock reference with given name reference.
clearMock(name: String): void
Clears all mock references
clearAllMocks(void): void
MixRecipe is a guide object.
rootDir: string defaults: process.cwd()