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

Captured arguments are changed by object changes #218

Open
namse opened this issue Jul 26, 2021 · 1 comment
Open

Captured arguments are changed by object changes #218

namse opened this issue Jul 26, 2021 · 1 comment

Comments

@namse
Copy link

namse commented Jul 26, 2021

I found that captured action(or method)'s arguments are changed when I change the object that I passed as argument.

for example,

class A {
  foo(b) {
  }
}

const mockedA = mock(A);
const instanceA = instance(mockedA);
const argument = {};
instanceA.foo(argument);
argument.c = 5;
const [firstArg] = capture(mockedFoo.foo).last();
console.log(firstArg) // print { c: 5 } ! I expected it prints { } because I pass {}.

I guess captured argument should be serialized

@NagRock
Copy link
Owner

NagRock commented Nov 17, 2021

But what then if you would like to compare instances?

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