Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

chai-callslike

Codibre3.2kMIT1.2.8TypeScript support: included

A simple sinon-chai assertion to validate many aspects of stub calls

sinon, chai, assertions, calls

readme

chai-callslike

build test lint Test Coverage Maintainability Packages npm version

A simple assertion to validate many aspects of stub calls. It is supposed to use with sinon + chai.

How it works

expect(stub).callsLike

Will validate the exactly interaction with the mocked method, which is:

  • How many times has been called;
  • Which parameters have been passed to it;
  • In what order the calls happened.

How to use?

It is pretty simple to setup the chai-callslike in your tests:

import chai from 'chai'
import {callsLike} from 'chai-callslike'

chai.use(callsLike)

Just pass the stub in the first parameter and, in the others, arrays with the set of parameters each calls had received.

expect(myStub).callsLike(
  ['param1call1', 'param2call1', 'param3call1'],
  ['param1call2', 'param2call2', 'param3call2'],
 );

If you want to check if the stub had never been called, pass just the stub:

expect(myStub).callsLike();

If you expect the stub to have been called with no parameters, pass empty arrays:

expect(myStub).callsLike([], [], [])

(in this example, myStub have been called three times with no parameters)

You can also use sinon matchers to validate the parameters instead of exact values:

expect(myStub).callsLike(
  [sinon.match.object, sinon.match.string, sinon.match(/.+foo.+goo/)]
 );

The generated log will look pretty as this:

If if didn't show up, take a look in the resources folder!

For more info look into the Full API Reference.

changelog

1.2.8

  • d4eabe9 Merge pull request #22 from Codibre/update-readme-file
  • 77b65f2 docs: adding some information to the readme file

    v1.2.7

  • 4680827 1.2.7
  • db65779 Merge pull request #21 from Codibre/hotfix-remove-lib-vulnerabilities
  • 782161c decrease del-cli version in order to keep node 10 compatibility
  • 95c727c install new libs
  • 5b26cb2 1.2.7
  • 1c0ee3b fix: fixes required by eslint
  • 543852d fix: update @codibre/confs to newest version and remove handlebars critical vulnerability

    v1.2.6

  • a843f04 1.2.6
  • 624e2d8 fixing package.json
  • 209e835 Issue 18 real fix (#20)

    v1.2.5

  • 9299ba7 1.2.5
  • 6a911c5 Merge branch 'master' of github.com:Codibre/chai-callslike into issue-18-Asserting_an_recursive_object_throws_and_error
  • 61e1fec 1.2.4
  • ab37ba3 fixing empty object comparison
  • a6490db Issue 14 is json comparable fails if value is null (#17)

    v1.2.4

  • 24c43ac 1.2.4
  • 544d47a fixing null comparing
  • d0f4a34 Merge pull request #13 from Codibre/issue-10-Errpr_when_comparing_to_undefined
  • 3be0212 Merge pull request #12 from Codibre/issue-10-Errpr_when_comparing_to_undefined
  • 3efabd8 Merge pull request #11 from Codibre/issue-10-Errpr_when_comparing_to_undefined

    v1.2.3

  • 1f867a7 1.2.3
  • 56203da undoing stack change
  • 13ea24d fixing doc

    v1.2.2

  • 08763c0 1.2.2
  • 40ea915 bettering call stack

    v1.2.1

  • 28b7d6d 1.2.1
  • 0c35fa3 fixing undefined comparison
  • c9f7ea9 Merge pull request #9 from Codibre/new-release
  • 05a6bf7 fixing publish yml
  • 10e4d5c Merge pull request #8 from Codibre/new-release
  • 97a3975 updating docs"
  • 4183af7 Merge branch 'master' of github.com:Codibre/chai-callslike into new-release
  • 1f7c5c7 Merge pull request #6 from Codibre/issue-2-testing_non_stub_throws_an_untreated_error
  • 69e9186 Merge branch 'master' of github.com:Codibre/chai-callslike into issue-2-testing_non_stub_throws_an_untreated_error
  • f87210d fixing lint
  • 6ffd7d4 checking if is stub

    v1.2.0

  • c90dac6 1.2.0
  • da204bf Merge pull request #7 from Codibre/issue-4-expose_object_compare_function
  • f86b20e adding phrase to assertion message
  • 08678ac fixing lint
  • 2c2f501 adding test case
  • dad08eb creating like method
  • 58f9b56 Merge pull request #5 from Codibre/issue-1-String_assertion_passing_with_partial_string
  • 5706c54 fixing readme and flag
  • a99bbb8 fixing some things
  • 96fbfb2 fixing implementation with shouldFailOnExactCompare
  • 8cac670 fixing new assertion
  • fe4c355 Update README.md

    v1.1.2

  • 582ef93 1.1.2
  • 77f447b fixing references to github

    v1.1.1

  • 5ac6e61 1.1.1
  • 28682ff updating github badges

    v1.1.0

  • f3161a6 1.1.0
  • 2ad86ab 1.0.0
  • ba44605 preparing for version release
  • 29e138c preparing for version release
  • 7dc8c18 updating readme properly
  • 23ddeb4 configuring project for new name
  • 734cb4f updating changelog
  • a5f8384 2.3.0
  • c727d37 added help
  • c190c64 updating changelog
  • f557a65 2.2.6
  • 25de5b9 fixing package size
  • 5e565d0 removing npmignore
  • 7b1e71d updating changelog
  • ab461ca 2.2.5
  • a07acf7 Fixing actual expected order
  • c16534d updating readme
  • edac0fa updating example image
  • e3000e8 updating changelog
  • dc4fff3 2.2.4
  • a8886f1 removing unused dependency
  • d3f1bb3 updating changelog
  • eb8c0b4 2.2.3
  • 324f9be fix vulnerabilities
  • ac0fc73 finalizing betterarization of logs
  • b7a5399 version bump
  • c91aeaf 2.2.2
  • 75268ab bettering again object diff
  • af3ea12 version bump
  • 520c3dc 2.2.1
  • 4addd51 fixing obj colors
  • aec2f6e bettering object types diff
  • 57673d2 2.2.0
  • 5c9dc1e betterning betterning betterning diff descriptions
  • ecdeb45 2.1.2
  • b622459 removing codecov
  • 6cc7240 testing codeclimate
  • c5411bc updating paambaati
  • 94eff4b fixing pl
  • 4e99742 testing coverage climate
  • 4fea253 resolving code smells
  • c4734ca updating changelog
  • 2784d55 2.1.1
  • 1ffe176 betterning even more log
  • 6117fdc removing travis! Thanks for your services until now
  • a400db1 test only on 10.x
  • b0b5332 codecov directly from github
  • a06f0a1 fixing action name
  • 53ff2a7 segregating actions
  • df0816d updating travis
  • 6f66900 creating github action
  • 347e3c6 updating changelog
  • af5e528 2.1.0
  • 729bff7 Updating changelog
  • da1b4b7 much better messages
  • 13dac06 fixing unit tests and segregating code
  • 09bcba3 fixing assertion
  • c2dcac0 2.0.6
  • d67c91e fixing assertion
  • ae64a25 updating changelog
  • 64ec449 2.0.5
  • 274f665 fixing assertions I broker in later commits. sorry
  • 1e94439 updating changelog
  • 300e544 2.0.4
  • 002292d changing codibre to dev dependency
  • bc6780d updating changelog
  • 0dcb445 2.0.3
  • 2b56115 creating option to pass sinon refernce
  • 69c33bb updating changelog
  • 9269251 2.0.2
  • 177564a updating prepublish script
  • 18678ee updating changelog
  • a3ecce5 2.0.1
  • c8bf444 updating git ignore
  • a41ae8c creating callsLikeExactly and updating base config
  • 84b7252 2.0.0
  • 98e3698 Updating base config
  • aecfb78 fixing base config
  • 823ade4 1.5.7
  • 7eabf6f updating base config project
  • 67f1203 fixing typing
  • 542f865 fixing exportion
  • 3bc6cea 1.5.6
  • fb02c79 fixing chai declaration
  • fc2e048 fixing typings
  • d55b0bb 1.5.5
  • 2a69457 changing typing definition
  • 853c571 changing typing definition
  • cea3be1 1.5.4
  • b6e3a0f fixing chai addition of method
  • 3488504 adding npmrc to git ignore
  • 51f5d5f making mocha dev dependency
  • f716e82 1.5.3
  • ce31188 Betterning comparison
  • 163e72e 1.5.2
  • 0a3def5 Merge branch 'master' of github.com:Farenheith/sinon-chai-calls-assertion
  • 8eb1bee fixing beforeEach and afterEach usage
  • d82b45f prepublish script
  • b84eda6 version bump
  • 303c77c Adding badges to readme and updating readme.md
  • e05ea35 fixing packages tag
  • 377f909 adding build to gitignore
  • eb4851d Removing build folder
  • 243d768 adding badges and updating base-project-config
  • 05f9bf0 version bump
  • fe8e3c4 removing garbage
  • 9eb4075 fixing typings
  • a9caba4 fixing typings
  • 7cd42b4 fixing typings
  • cfe7406 testing typing
  • 1e5d21c Fixing base-project-config to be not just a dev dependency
  • 05eab64 Bumping version
  • 7e9103c adding base-project-config
  • e30c433 creating constructor stubber
  • 7bea70f Patternalizing lib usage
  • 3e5b649 updated version and readme.md
  • 650bb32 lib setted to chai fluent format
  • fe4bab6 Update README.md
  • 2699d48 Update README.md
  • 8416314 Update README.md
  • b4433a5 Update README.md

    v1.0.3

  • 6dfdef4 Fixing package.json main
  • 1c482df fixing package.json start
  • 5d9db47 Fixing package option

    v1.0.1

  • b6cd824 Fixing compilng config

    v1.0.0

    v.1.0.2

  • 5d9db47 Fixing package option
  • b6cd824 Fixing compilng config
  • aecdfad changin sinon-chai to be devDependency
  • f8b8916 Initial commit