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

expect.equal(json1, json2) fails with Values have same structure but are not reference-equal #4792

Closed
eladb opened this issue Nov 3, 2023 · 4 comments · Fixed by #5554
Closed
Assignees
Labels
🐛 bug Something isn't working 🧪 testing

Comments

@eladb
Copy link
Contributor

eladb commented Nov 3, 2023

I tried this:

The expect.equal() method is failing because of #4118

This happened:

Something like this:

     │ AssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:
     │ 
     │ {
     │   producer_result: {
     │     result: 12
     │   }
     │ }
     │ 
     │     at Util.equal (/var/folders/vm/cm444l3124j_vh_8rkhz6kqm0000gn/T/wing-bundles-XhI7xo/index.js:5449:26)
     │     at $Closure1.handle (/var/folders/vm/cm444l3124j_vh_8rkhz6kqm0000gn/T/wing-bundles-XhI7xo/index.js:34:38)
     │     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     └     at async exports.handler (/var/folders/vm/cm444l3124j_vh_8rkhz6kqm0000gn/T/wing-bundles-XhI7xo/index.js:5685:10)
 

I expected this:

To work

Is there a workaround?

stringify the objects

Component

SDK

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Anything else?

@skorfmann until we fix the VM issue that's the root cause, let's just change the expect.equal library to use JSON.stringify() in case it compares to objects, ok?

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@eladb eladb added the 🐛 bug Something isn't working label Nov 3, 2023
@skorfmann
Copy link
Contributor

Yes, that's a bit annoying :) However, this will behave differently though

  • Object properties are compared unordered.
  • Map keys and Set items are compared unordered.

So, this will be breaking change when going back to a non stringified comparison.

If that's acceptable then let's change it. Alternatively, a user should be able to do stringify the values in such cases as well. Don't know how frequent that is.

@eladb
Copy link
Contributor Author

eladb commented Nov 3, 2023

If that's acceptable then let's change it

It's acceptable at this point I think.

Copy link

github-actions bot commented Jan 5, 2024

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days.
Feel free to re-open this issue when there's an update or relevant information to be added.
Thanks!

@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.59.43.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🧪 testing
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants