kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

When route not found during testing, don't log error #615

Open lorensr opened 8 years ago

lorensr commented 8 years ago

meteor/todos is currently throwing this error on the client during meteor test.

https://github.com/meteor/todos/issues/130#issuecomment-217016579

bcbrian commented 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?

rafa-munoz commented 8 years ago

👍 It's really annoying that message

serut commented 7 years ago

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... !

s-devaney commented 7 years ago

+1 please merge

diegonc commented 7 years ago

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

HugoHeneault commented 7 years ago

Could this be merged soon? :+1:

aadamsx commented 7 years ago

Would you mind submitting this PR to FineRouter too?

SimonSimCity commented 5 years ago

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() {
  },
};