Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-spies-augment

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-spies-augment

Additions to chai-spies, adding utilities to inspect args and check if a spy was called with a partial object

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
increased by57.57%
Maintainers
1
Weekly downloads
 
Created
Source

chai-spies-augment

Additions to the chai-spies library

Adds:

  • Ability to easily inspect the parameters a spy has been called with
  • Ability to check if a spy was called with a partial object

Install

npm install --save-dev chai-spies-augment

Then in your test setup file where you are loading chai spies

import chaiSpies from 'chai-spies';
import chaiSpiesAugment from 'chai-spies-augment';
...
chai.use(chaiSpies);
chai.use(chaiSpiesAugment);

Usage

Accessing spy call parameters

const spy = chai.spy();
 
spy(1, 2, 3);
spy('a', 'b', 'c');
 
const args = spy.args(); // ['a', 'b', 'c']
const argsFor = spy.argsFor(0); // [1, 2, 3] 

Checking for partial object

const spy = chai.spy();
 
spy({ a: 'b', c: 'd' });
spy(1, 'a', { b: 'c' });
 
expect(spy).to.have.been.called.with.objectContaining({ a: 'b' }); // true
expect(spy).to.have.been.called.with.objectContaining({ b: 'c' }); // true

Keywords

FAQs

Package last updated on 18 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc