0👍
I think I’ve did it using jest.isolateModules
with require
instead of import:
beforeEach(() => {
jest.isolateModules(() => {
myModule = require("./useFoo.");
});
});
it("working test", () => {
const { state } = myModule.useRoutes();
expect(state.value).toEqual([]);
}
it("previously failed test", () => {
const { state } = myModule.useRoutes();
expect(state.value).toEqual([]); // this is now working
}
This ensures that the module is reimported before each test, which initializes the singleton/state again.
- [Vuejs]-404 response when deploy vuejs using "npm run build"
- [Vuejs]-Trying to calculate the width of a text in my Nuxt App
Source:stackexchange.com