nanospy

Spy and mock methods in tests with great TypeScript support

MIT 12 个版本
安装
npm install nanospy
yarn add nanospy
pnpm add nanospy
bun add nanospy
README

Nano Spy

A tiny Node.js library to spy and mock methods in tests with great TypeScript support.

It will take only 6 KB in your node_modules and have 0 dependencies.

import { spyOn, restoreAll } from 'nanospy'

test.after.each(() => {
  restoreAll()
})

test('calls increase', () => {
  const spy = spyOn(counter, 'increase')
  counter.increase(5)
  assert.equal(spy.callCount, 1)
  assert.equal(spy.calls, [[5]])
})
Sponsored by Evil Martians
版本列表
2.0.2 2026-06-27
2.0.1 2026-06-19
2.0.0 2026-06-19
1.0.0 2023-06-21
0.5.0 2022-02-04
0.4.0 2021-11-26
0.3.2 2021-11-25
0.3.1 2021-11-24
0.3.0 2021-11-21
0.2.1 2021-11-21
0.2.0 2021-11-20
0.1.0 2021-11-20