If I have a class that takes a `org.w3c.dom.Histor...
# javascript
e
If I have a class that takes a
org.w3c.dom.History
how can I unit test that class with a fake/mock
org.w3c.dom.History
?
t
globalThis.History = MyHistoryMock
?
e
How do I mock it? It seems like I can't do anything with it because it is
external
Copy code
public external abstract class History : JsAny
t
Where declared
JsAny
? 🤔
> It seems like I can't do anything with it because it is
external
Is it mock method limitation?
e
If I do
class FakeHistory : org.w3c.dom.History()
I get an error that says
Non-external type extends external type History
t
Extending doesn't work -
History
has no public constructors
Real browser
History
e
Right, so how am I supposed to unit test without a real one?
t
globalThis.History = MyHistoryMock
e
So it's not possible to unit test outside of the browser?
e
I've just compiled fine with an extension of
History
. Mmm maybe I'm doing something wrong?
Ahhh are you working in the WASM side?
JsAny
comes from the WASM stdlib.
This seems to be a limitation of the WASM JS target.
🤔 1