-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Add some jest-extended
matchers to bun test
#13628
base: main
Are you sure you want to change the base?
feat: Add some jest-extended
matchers to bun test
#13628
Conversation
jest-extended
matchers to bun test
jest-extended
matchers to bun test
jest-extended
matchers to bun test
@Jarred-Sumner Code updated, ready for review. Thanks |
var pass = false; | ||
|
||
if (!value.isUndefinedOrNull()) { | ||
const key = expected.getIndex(globalObject, 0); |
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.
const key = expected.getIndex(globalObject, 0); | |
const key = expected.getIndex(globalObject, 0); | |
if (globalObject.hasException()) return .zero; |
Each getIndex
call will need to check for exceptions. It's possible for the array to throw
var obj = { a: 1 };
var arr = ["a"];
Object.defineProperty(arr, 1, {
get: function() {
throw new Error("error");
}
enumerable: true,
}
expect(obj).toContainEntry(arr);
defer key_string.deref(); | ||
|
||
const property_value = expected.getIndex(globalObject, 1); | ||
const accessed_property_value = value.getOwn(globalObject, key_string) orelse JSValue.undefined; |
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.
I think the orelse
case should set pass = false
. Currently this test will pass when it should fail:
expect({}).toContainEntry([ a, 1 ]);
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.
Applies similarly to toContainEntries
, toContainAllEntries
, and toContainAnyEntries
What does this PR do?
Add
toContainEntry
toContainEntries
toContainAllEntries
toContainAnyEntries
from #1825How did you verify your code works?
bun-debug test jest-extended.test.js
)