Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to.have.been.called.with() throws an error #78

Closed
Bartosz-D3V opened this issue Aug 27, 2017 · 3 comments
Closed

to.have.been.called.with() throws an error #78

Bartosz-D3V opened this issue Aug 27, 2017 · 3 comments

Comments

@Bartosz-D3V
Copy link

Hi there,

I have a small issue with chai spies.

import * as spies from 'chai-spies';
const assert = chai.assert;
const expect = chai.expect;

beforeEach(() => {
chai.use(spies);
spy = chai.spy.on(component.change, 'emit');
});

it('should have been called with string foo', () => {
expect(spy).to.have.been.called.with('foo');
});

When invoking the above code I receive an error:

Error: Invalid Chai property: _his. Did you mean "is"?
at Object.proxyGetter [as get] (node_modules/chai/chai.js:9105:17)

I don't have any problems with running other functions so far like to.have.been.called.once/twice etc.

Is it a known issue?
I use chai version 4.0.2 and chai-spies version 0.7.1

@stalniy
Copy link
Contributor

stalniy commented Aug 27, 2017

Duplicates #71

Update:
Fixed in #77 waiting for review from @keithamus

@shellscape
Copy link

@Bartosz-D3V I've published chai-spies-next that you can use in the meantime. It was actually rather trivial to fix folio to run a build so I'm not sure why that's been blocking on a new build.

bors bot added a commit to IMA-WorldHealth/bhima that referenced this issue Dec 1, 2017
2321: Write unit tests for topic.js r=jeremielodi a=jniles

This PR adds tests for the topic.js library, a pub-sub system based on ioredis.

First, I have added a global setup function and teardown function (which is empty currently) for the server-unit tests.  These functions pre-load the environmental variables and setup up Chai with spies and promises.  These are located in `setup.js` in the `test/server-unit` directory.  See mochajs/mocha#1460 (comment) for the suggestion for this code.

Second, I've added unit tests to the topic library.  They use a spy plugin for chai to detect when callbacks have been fired.  Unfortunately, due to bugs with the `chai-spies` library (chaijs/chai-spies#78) I've had to use [chai-spies-next](https://www.npmjs.com/package/chai-spies-next).  In order to wait for the asynchronous code to complete, each spied function returns a
promise that determines when the testing should proceed.  If no actionhappens withing mocha's default timeout, the test fails.

Closes #2314.
@stalniy
Copy link
Contributor

stalniy commented Jan 10, 2018

Fixed in 1.0.0

@stalniy stalniy closed this as completed Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants