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

Vue Router testing error: Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Timeout #1088

Closed
ZaeemKhaliq opened this issue Nov 18, 2021 · 1 comment

Comments

@ZaeemKhaliq
Copy link

Following the official Next Vue Test Utils documentation, I am testing a component which has <router-link> following the 'Real Router' section of the documentation.
On the documentation it says: -

'Vue Router provides an isReady function that tell us when router is ready. We can then await it to ensure the initial navigation has happened.'

So, I added the code

import route from "../../../../src/router/index";

const router = route();

it("Should render a value", async () => {
    await router.isReady();

    const wrapper = mount(Cards, {
      global: {
        plugins: [router],
      },
    });

    const value = wrapper.find(".value");

    expect(value.text()).toBeTruthy();

But it's giving the following error: -

: Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Error:

      14 |
      15 | describe("Cards", () => {
    > 16 |   it("Should render a value", async () => {
         |   ^
      17 |     await router.isReady();
      18 |
      19 |     const $store = {

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.<anonymous> (test/jest/__tests__/Home/Cards.spec.js:16:3)
      at Object.<anonymous> (test/jest/__tests__/Home/Cards.spec.js:15:1)

I even tried increasing the timeout to 30000 but still causes the same issue.
What could cause the above issue?

Also I am using quasar framework. Don't know if it's related to that but I think it's related to jest or vue utils. Please help regarding this.

@cexbrayat
Copy link
Member

Hi @ZaeemKhaliq

It's hard to say without your code, but I don't think there is an issue with VTU here.

You can find more info about tests with the router here, but I strongly recommend you to use a mock router instead, as it is way easier.

You can check out https://github.com/posva/vue-router-mock/ It is what we use in our company, and what I teach in my course as it does a great job to avoid all these problems.

I'm going to close the issue. If you think you encounter a bug with VTU, please reopen with a reproduction we can run, ideally a small Github repo with the minimum to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants