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

Reporter tests affected by shallow cloning #3554

Closed
plroebuck opened this issue Nov 5, 2018 · 4 comments · Fixed by #3888
Closed

Reporter tests affected by shallow cloning #3554

plroebuck opened this issue Nov 5, 2018 · 4 comments · Fixed by #3888
Labels
type: bug a defect, confirmed by a maintainer

Comments

@plroebuck
Copy link
Contributor

Description

While updating our reporter test code, it has been discovered that many tests are restoring aspects of the tested objects due to use of shallow cloning. Typically, the test code makes a copy of the affected object, mutates it temporarily, then restores it. Problem is that making a copy via assignment of an object does not work protect its properties, and those "twiddled" properties are still present in the original when restored. We need a "deep clone" method, and then to apply it to all reporter specs.

While not evaluated elsewhere (yet), it is almost certain this problem is far more widespread.

Versions

Mocha 5.2 (past & future)

@plroebuck plroebuck added type: bug a defect, confirmed by a maintainer qa labels Nov 5, 2018
@boneskull
Copy link
Contributor

Do you have an example...?

@outsideris
Copy link
Contributor

Maybe this one?

@plroebuck
Copy link
Contributor Author

From the article How To Copy Objects in JavaScript:

  • cloner - An ES5+ compatible utility to deep or shallow copy and merge objects.

@boneskull
Copy link
Contributor

Couldn't this just be solved by using e.g., Sinon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants