Skip to content
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

Provide a way to disable warnings for MATCHER_NOT_FOUND when testing #358

Closed
cexbrayat opened this issue Jul 6, 2020 · 2 comments
Closed

Comments

@cexbrayat
Copy link
Member

When adding tests to a component using the router, one might need to provide a mock router. I currently use:

const mockRouter = createRouter({ history: createWebHistory(), routes: [] });
describe('Navbar.vue', () => {
  test('should ...', () => {
    const navbar = mount(Navbar, {
      global: {
        plugins: [mockRouter],
        stubs: {
          RouterLink: RouterLinkStub
        }
      }
    });
    // ...
  });
});

It works perfectly, but the router emits a warning:

console.warn node_modules/vue-router/dist/vue-router.cjs.js:225
    [Vue Router warn]: No match found for location with path "/"

As most tests are using the same code, the warning is emitted a lot and pollutes the test output.
Until VTU or the router itself provides built-in support for testing (if ever, see vuejs/test-utils#152 for curious readers), do you think we could guard this warning with a setting to hide it? I can open a PR if you provide some guidance (and think this is useful of course).

@vue-bot
Copy link
Collaborator

vue-bot commented Jul 6, 2020

Hello, thank you for taking time filling this issue!

However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!).

I hope to see your helper-created issue very soon!

@vue-bot vue-bot closed this as completed Jul 6, 2020
@posva
Copy link
Member

posva commented May 3, 2023

Duplicate of #359

@posva posva marked this as a duplicate of #359 May 3, 2023
@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2023
@vuejs vuejs locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants