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

Chai subset executes redux-saga call? #68

Open
clementhannicq opened this issue Dec 21, 2017 · 1 comment
Open

Chai subset executes redux-saga call? #68

clementhannicq opened this issue Dec 21, 2017 · 1 comment

Comments

@clementhannicq
Copy link

clementhannicq commented Dec 21, 2017

Hello, I was using chai-subset to test a generator function(using redux-saga)

Running the following snippet does not execute fn

const {value} = mySaga.next();
const object = call(fn, param);

console.log(object);

Running this one runs the function fn

const {value} = mySaga.next();
const object = call(fn, param);

expect(value).to.containSubset(object);

To be noted, using deep.equal does not execute it

const {value} = mySaga.next();
const object = call(fn, param);

expect(value).to.deep.equal(object);

If you are unfamiliar with redux-saga, call returns an object containing the function and its parameters

EDIT:
After reading the README, I figure it happens because chai-subset allows functions to compare values,
renhancement proposal: add a setting to disable function execution

@elmigranto
Copy link

elmigranto commented Sep 30, 2018

Yeah, when it sees a function, it calls it, which in addition to not making it possible to compare functions, throws a TypeError on constructors.

You can transform your object so when it sees a function in value, it replaces it with a check that comparing against that value, or, alternatively, 1.5.0 should work which is version before #66 was merged. @clementhannicq

@eagleeye that's a great module, thanks for making it public, but not being able to compare values without boilerplate is somewhat a big bug for this kind of lib. I feel that current behaviour is very niche and should be either reverted or made opt-in (also, breaking change between 1.5.0 and 1.6.0).

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

2 participants