-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
feat: use DiffFormatter
for expect's toHaveBeenNthCalledWith
#9002
base: main
Are you sure you want to change the base?
Conversation
c64796e
to
c7db7d9
Compare
// handle failure | ||
var formatter = JSC.ConsoleObject.Formatter{ .globalThis = globalObject, .quote_strings = true }; | ||
const received_fmt = nthCallValue.toFmt(globalObject, &formatter); | ||
const received = JSValue.createEmptyArray(globalObject, nthCallValue.getLength(globalObject)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSC has a way to call JSC::constructArray()
from a JSC::ArgList
. JSC::ArgList
can be constructed from a JSC::CallFrame
.
I also wonder if we could add a slice() binding since that's what we want here (not literally calling Array.prototype.slice but an internal function which performs a similar operation)
Maybe we should add a binding for to JSC.CallFrame
(zig) that calls JSC::constructArray
instead of doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The status quo is very broken, can we follow up on this?
This pull request is stale and may be closed due to inactivity. |
warning - this is my first time writing zig, so this might be not be the best way todo it 🙂
What does this PR do?
uses
DiffFormatter
to show a richer diff when usingexpect(mock).toHaveBeenNthCalledWith()
Previously:
Now:
It does this by first convertin the arguments (expected) and recieved to a JSArray and then passing these to the DiffFormatter
How did you verify your code works?
I tested it manually - i couldn't see any automated tests (snapshot) for these so didn't write any. If you want me to add tests, let me know
bun-debug test test-file-name.test
)^^ not sure about these especially the first/third