Open lorensr opened 8 years ago
This fix would be amazing! :+1:
When using practicalmeteor:mocha-console-runner a long with spacejam the following error is thrown. There is no route for the path: /local
because it is going to the route http://localhost:3100/local
. This cause my console unit tests to fail.
I currently have this file loaded at the beginning of all my *.tests.jsx
and client side *.tests.js
.
import { FlowRouter } from 'meteor/kadira:flow-router';
FlowRouter.route('/', {
name: 'hack route for tests',
action() {},
});
FlowRouter.route('/local', {
name: 'hack route for tests',
action() {},
});
This hackish solution works, but a fix in the code like suggested would do wonders.
@arunoda How do you handle this issue currently?
👍 It's really annoying that message
This pull request is working so great ! When you are running an app in the test mode, the library doesn't have any route and it just crashes. The test if(!Meteor.isTest && !Meteor.isPackageTest)
is perfect for ignoring these errors.
console.trace
is not implemented on phantomjs so my previous note is useless.
https://github.com/serut/todos use that fix and it works great.
It's related to A LOT of issues, so please do something to fix it: https://github.com/practicalmeteor/spacejam/issues/65 https://github.com/meteor/todos/issues/129 https://github.com/kadirahq/flow-router/issues/668 https://github.com/serut/meteor-coverage-app-exemple/issues/1 https://forums.meteor.com/t/spacejam-phantomjs-no-route-for-the-path-local-flowrouter/25233 https://forums.meteor.com/t/no-route-for-path-error-running-unit-tests/21560/4 It's time to react... !
+1 please merge
This is just hiding an annoying message (console.error
doesn't throw thus the control flow is not interrupted) and not fixing the underlying problem.
Ok, I'm not sure about console runners maybe there it is a problem like the message being printed to stderr and confusing the runner. But the web driver has other problems too.
When running meteor test
with the practicalmeteor:mocha
driver, the page displayed in the browser that summarises the results has links to browse them (go into one section, go up, etc) which don't work
at all when flow-router
is installed even if this patch is applied. @bcbrian hack didn't work either because flow-router still intercepts the location change.
What seems to work is
Intercepting clicks before flow-router gets them
if (Meteor.isClient) {
FlowRouter.wait();
Meteor.startup(function () {
document.addEventListener("click" , function (e) {
// ensure link
// use shadow dom when available
var el = e.path ? e.path[0] : e.target;
while (el && 'A' !== el.nodeName) el = el.parentNode;
if (!el || 'A' !== el.nodeName) return;
/* don't allow flow router to handle the event */
e.stopPropagation();
e.stopImmediatePropagation();
});
FlowRouter.initialize();
});
}
Or alternatively, leaving flow-router
wait forever :smile:
if (Meteor.isClient) {
FlowRouter.wait();
}
rel="external"
to links generated by practical:mocha
(flow-router ignores them, do other routers do the same though?)Could this be merged soon? :+1:
Would you mind submitting this PR to FineRouter too?
Found this while still struggling. Here's a work-around:
Create a file that is loaded by the test-suite (by e.g. calling it routing.test.js
) containing the following lines:
import { FlowRouter } from 'meteor/kadira:flow-router';
// Needed to initialize the routing when testing.
FlowRouter.notFound = {
action() {
},
};
meteor/todos
is currently throwing this error on the client duringmeteor test
.https://github.com/meteor/todos/issues/130#issuecomment-217016579