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

Same fixture object returned on multiple loads #14

Closed
epb-644 opened this issue May 11, 2016 · 1 comment
Closed

Same fixture object returned on multiple loads #14

epb-644 opened this issue May 11, 2016 · 1 comment

Comments

@epb-644
Copy link

epb-644 commented May 11, 2016

I just found a bug in my code caused by this unexpected behavior of fixture.load:

let fixtureObj = fixture.load('myfixture.json')
console.log(fixtureObj.testVal) // -> prints "undefined" (which is expected)
fixtureObj.testVal = 'foo'
fixtureObj = fixture.load('myfixture.json')
console.log(fixtureObj.testVal) // -> prints "foo" (which is not expected)

It seems that fixture.load returns the same instance of the object on each call, and thus subsequent calls will see any mutations on the object.

Would it be possible to deep clone the object before returning it via fixture.load? This would eliminate the issues I've seen.

@billtrik
Copy link
Owner

Hey @eddieburns55,

This was fixed in 0.2.6

please check #12 (comment)

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