Code Monkey home page Code Monkey logo

simple-spy's Introduction

simple-spy Coverage Status

yet another spy library

Install

$ npm install --save-dev simple-spy

Usage

Live test the package and types in this Stackblitz container: https://stackblitz.com/edit/vitest-dev-vitest-ykic5d?file=test/basic.test.ts

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

simple-spy's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar mightyiam avatar oskarkivra avatar renovate-bot avatar renovate[bot] avatar tjoskar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

simple-spy's Issues

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 1.9.0 to 1.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of @typescript-eslint/parser is breaking the build 🚨

The devDependency @typescript-eslint/parser was updated from 1.9.0 to 1.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v2
  • actions/setup-node v2
npm
package.json
  • typescript 5.5.2
  • xo 0.56.0
  • node >=16
  • node 18.5.0

  • Check this box to trigger a request for Renovate to run again on this repository

Accept undefined as function

From time to time I just want to create a mock and do not care about the return value of a function, often for functions that create side effects.

To mock these functions I currently have to do something like:

const myMock = spy(() => null);

I want to be able to just call spy without arguments:

const myMock = spy();

Implementation suggestion:

-function spy(fn) {
+function spy(fn = () => undefined) {

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 1.5.0 to 1.6.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 12 commits.

  • ab3c1a1 chore: publish v1.6.0
  • a4f95d3 feat(*): change TypeScript version range to >=3.2.1 <3.5.0 (#399)
  • 95a948d chore: initial pull request templates
  • 5d81f8c docs(eslint-plugin): fix markdown format (#394)
  • 492b737 fix(parser): Make eslint traverse enum id (#383)
  • f29d1c9 fix(eslint-plugin): Fix allowExpressions false positives in explicit-function-return-type and incorrect documentation (#388)
  • cebcfe6 fix(eslint-plugin): no-type-alias: fix typeof alias erroring (#380)
  • bf04398 fix(typescript-estree): add ExportDefaultDeclaration to union DeclarationStatement (#378)
  • 643a223 fix(eslint-plugin): explicit-function-return-type: ensure class arrow methods are validated (#377)
  • 6f5c0fa docs(eslint-plugin): list rules requiring type info (#360)
  • ad0f2be fix(eslint-plugin): member-naming false flagging constructors (#376)
  • bea6b92 feat(eslint-plugin): allow explicit variable type with arrow functions (#260)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

An in-range update of @typescript-eslint/eslint-plugin is breaking the build 🚨

The devDependency @typescript-eslint/eslint-plugin was updated from 2.9.0 to 2.10.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v2.10.0

2.10.0 (2019-12-02)

Bug Fixes

  • eslint-plugin: [no-empty-function] add missed node types (#1271) (e9d44f5)
  • eslint-plugin: [no-untyped-pub-sig] ignore set return (#1264) (6daff10)
  • eslint-plugin: [no-unused-expressions] ignore directives (#1285) (ce4c803)
  • eslint-plugin: [prefer-optional-chain] allow $ in identifiers (c72c3c1)
  • eslint-plugin: [prefer-optional-chain] handle more cases (#1261) (57ddba3)
  • eslint-plugin: [return-await] allow Any and Unknown (#1270) (ebf5e0a)
  • eslint-plugin: [strict-bool-expr] allow nullish coalescing (#1275) (3b39340)
  • typescript-estree: make FunctionDeclaration.body non-null (#1288) (dc73510)

Features

  • eslint-plugin: [no-empty-func] private/protected construct (#1267) (3b931ac)
  • eslint-plugin: [no-non-null-assert] add suggestion fixer (#1260) (e350a21)
  • eslint-plugin: [no-unnec-cond] support nullish coalescing (#1148) (96ef1e7)
  • eslint-plugin: [prefer-null-coal] opt for suggestion fixer (#1272) (f84eb96)
  • experimental-utils: add isSpaceBetween declaration to Sou… (#1268) (f83f04b)
Commits

The new version differs by 16 commits.

  • 5adb8a2 chore: publish v2.10.0
  • 065393b docs(eslint-plugin): typo in the configs README (#1295)
  • 96ef1e7 feat(eslint-plugin): [no-unnec-cond] support nullish coalescing (#1148)
  • e350a21 feat(eslint-plugin): [no-non-null-assert] add suggestion fixer (#1260)
  • ce4c803 fix(eslint-plugin): [no-unused-expressions] ignore directives (#1285)
  • f84eb96 feat(eslint-plugin): [prefer-null-coal] opt for suggestion fixer (#1272)
  • dc73510 fix(typescript-estree): make FunctionDeclaration.body non-null (#1288)
  • 3b39340 fix(eslint-plugin): [strict-bool-expr] allow nullish coalescing (#1275)
  • ebf5e0a fix(eslint-plugin): [return-await] allow Any and Unknown (#1270)
  • e9d44f5 fix(eslint-plugin): [no-empty-function] add missed node types (#1271)
  • 3b931ac feat(eslint-plugin): [no-empty-func] private/protected construct (#1267)
  • c72c3c1 fix(eslint-plugin): [prefer-optional-chain] allow $ in identifiers
  • f83f04b feat(experimental-utils): add isSpaceBetween declaration to Sou… (#1268)
  • 57ddba3 fix(eslint-plugin): [prefer-optional-chain] handle more cases (#1261)
  • 6daff10 fix(eslint-plugin): [no-untyped-pub-sig] ignore set return (#1264)

There are 16 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Lint

There should be linting as part of test script.

codecov

Following up from #15 (comment), I prefer codecov as well. I've had better experience with it.

An in-range update of typescript-eslint-parser is breaking the build 🚨

The devDependency typescript-eslint-parser was updated from 21.0.1 to 21.0.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

typescript-eslint-parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v21.0.2
  • fed0a5a Docs: Update README.md (#567) (dudiharush)
  • 47abd82 Fix: issue with global augmentation when tokens are not present (#574) (Armano)
  • c5ffad3 Fix: scope for TSImportEqualsDeclaration (#571) (Armano)
  • 8ff0ad1 Fix: missing implements in classes (#562) (Armano)
  • cc92044 Fix: visiting superTypeParameters in classes (#561) (Armano)
  • 83dbabb Fix: visiting typeParameters in expressions (#565) (Armano)
  • c19e479 Fix: visitor-keys for TSAbstractClassProperty (#560) (Armano)
  • 491ebca Fix: crash in no-unused-vars when using enum (#556) (Armano)
  • ae7c4e6 Fix: missing visitor-keys (#554) (Armano)
Commits

The new version differs by 11 commits.

  • 0c6c452 21.0.2
  • 5148ba2 Build: changelog update for 21.0.2
  • fed0a5a Docs: Update README.md (#567)
  • 47abd82 Fix: issue with global augmentation when tokens are not present (#574)
  • c5ffad3 Fix: scope for TSImportEqualsDeclaration (#571)
  • 8ff0ad1 Fix: missing implements in classes (#562)
  • cc92044 Fix: visiting superTypeParameters in classes (#561)
  • 83dbabb Fix: visiting typeParameters in expressions (#565)
  • c19e479 Fix: visitor-keys for TSAbstractClassProperty (#560)
  • 491ebca Fix: crash in no-unused-vars when using enum (#556)
  • ae7c4e6 Fix: missing visitor-keys (#554)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.