mimikry
v0.1.0
Published
Mocking and Stubing automation framework
Downloads
3
Maintainers
Readme
Mimikry
Mimikry is a Mocking and Stubing automation framework. Record stubs, and replay them whenever you need
Usage
import { Mimikry } from 'mimikry'
const mimikry = new Mimikry()
// A test class
class Datetime {
getDate (format) {
const date = new Date()
if (format === 'isodate') {
date.toISODate()
}
}
}
// Get date
const date = new Datetime()
// Returns a date string, depending on the current time
const isoDate = date.getDate()
// Record a stub, this has to be done only once.
mimikry.record('isoDateStub', date, 'getDate')
// Call the stubbed method
date.getDate()
// Now, replace the record() method with stub()
const stub = mimikry.stub('isoDateStub', date, 'getDate')
// Call the stubbed method again, it returns the same value on every call.
date.getDate()
// Remove the stub from class instance
stub.restore()
License
Licensed under the MIT License
Author
Andi Heinkelein @ Noname Media