simple-spy
TypeScript icon, indicating that this package has built-in type declarations

4.0.1 • Public • Published

simple-spy Coverage Status

yet another spy library

Install

$ npm install --save simple-spy

Usage

import { spy } from 'simple-spy'

const fun = (...args) => console.log(...args)
const funSpy = spy(fun)

assert(funSpy.callCount === 0)
assert(funSpy.args.length === 0)

funSpy('Hello Dexter Morgan') // Output:  Hello Dexter Morgan

assert(funSpy.callCount === 1)
assert(funSpy.args.length === 1)
assert(funSpy.args[0][0] === 'Hello Dexter Morgan')

funSpy.reset()

funSpy(1, 2, 3) // Output:  1 2 3

assert(funSpy.callCount === 1)
assert(funSpy.args.length === 1)
assert(funSpy.args[0].length === 3)
assert(funSpy.args[0][0] === 1)
assert(funSpy.args[0][1] === 2)
assert(funSpy.args[0][2] === 3)

API

spy(fun)

fun

Type: function

License

MIT © Oskar Karlsson

Readme

Keywords

Package Sidebar

Install

npm i simple-spy

Weekly Downloads

16

Version

4.0.1

License

MIT

Unpacked Size

17.4 kB

Total Files

11

Last publish

Collaborators

  • tjoskar