Skip to content

TypeError: Right-hand side of 'instanceof' is not callable thrown with vitest 1.x #4667

Answered by acelaya
acelaya asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks @hi-ogawa for the suggestion, but (global as any).URL = Object.assign(function () {}, { createObjectURL: () => '', }); throws a different error.

However, I started to wonder why I was mocking URL in the first place, as I don't see a clear reason. It turns out jsdom does not implement createObjectURL at the moment.

However, I don't need to overwrite the whole object, just add the missing method. Doing it like this solved the problem: (global as any).URL = Object.assign((global as any).URL, { createObjectURL: () => '' });.

Simply doing (global as any).URL.createObjectURL = () => ''; works as well.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@sheremet-va
Comment options

@acelaya
Comment options

acelaya Dec 5, 2023
Author Sponsor

Answer selected by acelaya
@hi-ogawa
Comment options

hi-ogawa Dec 5, 2023
Collaborator

@sheremet-va
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants