How do you test `browser` vs `node` given that <ht...
# webassembly
m
How do you test
browser
vs
node
given that https://youtrack.jetbrains.com/issue/KT-60802 is still an issue? Do you test only a single environment? Do a separate project specifically for testing the other environment? Something else?
o
I'm curious, what could be the reason to have different tests for browser vs NodeJS in one module?
m
The module is basically a network abstraction. Want to make sure it works with both browser and node http clients
o
But then you can just enable both sub-targets and run tests for both of them in a single module, right? Like in the case of Ktor, where
fetch
is used and tests are run for both sub-targets
m
Ah! Didn't know this was possible, I thought it was one or the other
😁 1
Just finished my day, will try it out tomorrow and report, thanks!
kodee happy 1
o
What Oleg said. Plus, of course, you'll be using the latest test infrastructure, (a.k.a. TestBalloon 😉), which gives you platform information at runtime, in case you really need that.
kodee loving 1
❤️ 1
m
Tried enabling both sub-targets, work like a charm but turns out I need different tests for browser and node still
Some of my tests use a MockServer that is only available in node environments
I could probably look into https://mswjs.io/docs/integrations/browser/ but that's a whole new project.
e
@mbonnin wdyt about opening an issue about ignore annotations specific to JS environments? For example
@Ignore(JsEnv.Browser)
That means you'd be able to write two different test case, but have a single one execute depending on the test environment. I still believe optionally splitting Node and browser source sets to be the best choice tho, but I'm losing the little remaining hope.
m
That wouldn't work because my mockserver is a dependency that doesn't ship wasmJs.
I'll stick with a separate project for my browser tests. It's working good enough for now.