We use a custom runner for testing.
Run webpack dev server
npm test:serve
Open another terminal and Run test runner
npm test:run
Then, runner will track changes from **.spec.js
files in specs
directory and its dependencies and run the needed test.
Spec file should export test method to default
.
import assert from 'assert'
import StorageManager from 'main/lib/StorageManager'
export default t => {
assert.ok(true)
}
On test environment, babel-plugin-rewire
is enabled.
You can replace any dependencies of a module by __Rewire__
method.
import loadAllStorages from 'main/lib/data/loadAllStorages'
const storageMock = require('storageMock')
loadAllStorages.__Rewire__('localStorage', storageMock)