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

Change mocks mid-test #2097

Open
steven-twerdochlib opened this issue Jul 26, 2024 · 0 comments
Open

Change mocks mid-test #2097

steven-twerdochlib opened this issue Jul 26, 2024 · 0 comments

Comments

@steven-twerdochlib
Copy link

Hi,
I would like to change a mock in my wrapper without having to recreate a whole new wrapper, is this possible?
Here's my wrapper:

  let wrapper;
  let store;
  let state;
  let getters;
  let $route = {
    meta: {
      app: 'testMeta1'
    }
  };
  const $router = {
    go: vi.fn()
  };
  state = {
    };
    getters = {
      }
    };
    const actions = {
    };
    store = createStore({
      getters,
      actions,
      state,
      mutations: {
        }
      }
    });

    wrapper = shallowMount(ImageViewer, {
      global: {
        plugins: [store],
        mocks: {
          $route,
          $router
        }
      }
    });

So what I would like to do is change the $route.meta.app for a specific test, to the below without having to create a whole new wrapper.

let $route = {
  meta: {
    app: 'testMeta2'
  }
};
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

1 participant