How to test "instance of" relationship with node test runner assert? #51158
-
In Jest we have an assertion like this: expect(x).toBeInstanceOf(y); Is there a way to test this with node test runner assert? node version: 20.9 LTS |
Beta Was this translation helpful? Give feedback.
Answered by
JimmyDaddy
Dec 15, 2023
Replies: 1 comment 1 reply
-
You can try this // if y is a instance of some class
assert.ok(x instanceof y.constructor);
// if y is a class
assert.ok(x instanceof y); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
varunkamra
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can try this
jest expect.toBeInstanceOf