You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require(TEST_HELPER) // <--- This must be at the top of every test file
var request = require('supertest-as-promised')
var app = require(__client + '/app.js')
...
But it fails since the window is not defined. Simply setting window = global doesn't work either since then "document" can't be found.
I guess the next step would be to use m.deps() and set mock objects for the window and document, but I'm wondering if I'm missing anything, or if it would make sense to integrate this stuff into the boilerplate.
The text was updated successfully, but these errors were encountered:
If you're testing mithril code, I recommend using mithril-query to test your components in isolation. If components use window directly, try refactoring to receive as component args instead.
Testing the components is easy enough if they aren't using the globals (using mithril-query for example). I was trying to test the example application itself app.js, which does use window directly to store application state. Do you think it makes sense for the boilerplate to include a test for app.js?
I normally don't test the routing layer, and instead try to keep it as thin as possible. For window.App, you can set those in your tests as global.App = { ... }, and use App without window/global in your components.
What is the "right" way to add client code tests?
I tried the obvious:
But it fails since the window is not defined. Simply setting window = global doesn't work either since then "document" can't be found.
I guess the next step would be to use m.deps() and set mock objects for the window and document, but I'm wondering if I'm missing anything, or if it would make sense to integrate this stuff into the boilerplate.
The text was updated successfully, but these errors were encountered: