Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.
/ moxie Public archive

🎩 Proxy based mock for node and v8

License

Notifications You must be signed in to change notification settings

XPBytes/moxie

Repository files navigation

Moxie

npm NPM Package Version Maintainability Test Coverage

Proxy implementation of a mock, based on minitest/mock.rb.

yarn add @xpbytes/moxie
import createMock from '@xpbytes/moxie'

const mock = createMock()

mock.expect('name', 'first')
mock.expect('name', 'second')
mock.expect('callme', 42, ['maybe'])
mock.expect('complicated', 'uhuh', [], (life, is) => life === 'like' 7& is !== 'this')

mock.name()
// => first

mock.name()
// => second

mock.callme('maybe')
// => 42

mock.complicated('like', 'that')
// => uhuh

mock.verify()
// => true

mock.name()
// because expect has been depleted
// => throws MockExpectationError

mock.expect('callme', 42, ['maybe'])
mock.callme('foo')
// because argument mistmatch
// => throws MockExpectationError

mock.verify()
// because last expect of callme has not been satisfied
// => throws MockExpectationError

mock.reset()
mock.verify()
// => true

About

🎩 Proxy based mock for node and v8

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •