-
Notifications
You must be signed in to change notification settings - Fork 595
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
Allow using jsdom
with a local window
on node for tests
#577
Comments
You can use jest, it works flawlessly with choo, maybe look for their jsdom implementation in their test runner |
Hmm, I wasn't aware |
I does have the whole shebang both node and clientside-wise, also coverage etc |
I tried testing using Jest and JSDom, and it works really well! To be honest, this just makes me crave a more lightweight solution even more, though. I think the Jest jsdom environment could be a great starting point! |
yup feel free to try implementing it lightweight, but isn't this just reinventing the wheel ? |
Well, it may be. However, I ultimately would want something we could include with |
https://github.com/developit/undom might be an option depending on needs |
that looks cool, i will have a look, and we can incorporate something nice @cjhowe7 if you want to i mean anything is good enough that doesn't require to run terrible chrome/chromium/electron/younameit browser session in a test runner. |
From experience anything that isn't a real browser will lead to issues –
speaking from years of trying out all different variations. [tape-run](
https://github.com/juliangruber/tape-run) seems the current best solution,
but having a headless Chrome / FireFox TAP runner a la [smokestack](
https://github.com/hughsk/smokestack) would be dope.
Also really dig the interactive feel of Jest – the way it allows filtering
tests is nicely done, and useful for building applications. Kinda wish it
was a lil more modular tho.
…On Fri, Oct 6, 2017 at 3:33 PM Maciej Sitko ***@***.***> wrote:
that looks cool, i will have a look, and we can incorporate that @cjhowe7
<https://github.com/cjhowe7>
i mean anything is good enough that doesn't require to run terrible
chrome/chromium/electron session in a test runner.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#577 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACWlegwGRCWqJfXXsBd_WkSc6-9VkKU2ks5spoCBgaJpZM4PwGb7>
.
|
yeah they made it a close box full-stack option which is a shame, although you can import their modules one by one and make something out of it - its still its a bit of an end-all solution for their convenience sake. from my experience, since my company switched to jest exclusively - it has proven to be rock-solid and idiot-proof low entry solution for all things JS, much better to browser based alternatives such as Karma. allows absolute no distinction between node and client-side (massive advantage). full testing isomorphism. just press & play. but hey fb team has capacity to invest in it so its decent. making something on a similar level is difficult, to say the least. |
I wanted to be able to simulate clicks / other events in my tests without needing to spin up a browser environment, so for me the trade-off of not really being in a browser is worth it at this time. So.... I hacked around a bit and came to a solution just now that's gross but super simple.. Hopefully over time I stumble into something nicer... but I thought I'd share where I'm at now in case it helps!: https://github.com/chinedufn/choo-test-onclick-example/blob/master/test.js tl;dr I'm making Again - hacky so YMMV I'd imagine.. |
I have been thinking about how we could write simple tests without needing a full-stack testing solution up front. I think we can already test most of our choo applications with tools like
assert-html
, but it would be nice to have a way to test DOM events.jsdom
seems like a perfect fit for this use case, but I'm not sure how I'd actually go about using it withchoo
. For one,app.mount
expects a global window object, but I want to pass in local window objects to allow running tests in parallel. I think it'd be nice if we had some middle ground in betweenapp.mount
andapp.toString
that allowed using a DOM implementation likejsdom
to render the application, but also allowed setting up an initial state and route likeapp.toString
.The text was updated successfully, but these errors were encountered: