Here is my code. I want to DRY up this case.
describe("Stored id", () => {
it("ID empty", () => {
// when
const wrapper = mount(SigninPage, options);
const vm = wrapper.vm;
});
it("ID exist", () => {
// when
localStorage.setItem(process.env.VUE_APP_SIGNIN_STORED_USER_ID, STORED_ID);
const wrapper = mount(SigninPage, options);
const vm = wrapper.vm;
});
});
How can I use the beforeEach hook like next using typescript?
I want to use the beforeEach hook. But I can not running test because of tsc. I think it will be possible when variable types is correct.
describe("Stored id", () => {
// problem
let wrapper: VueWrapper<??>;
let vm: ??;
beforeEach(() => {
wrapper = mount(SigninPage);
vm = wrapper.vm;
});
it("ID empty", () => {
// const wrapper = mount(SigninPage, options);
// const vm = wrapper.vm;
});
it("ID exist", () => {
// Should I save it before the wrapper is mounted?
localStorage.setItem(process.env.VUE_APP_SIGNIN_STORED_USER_ID, STORED_ID);
// const wrapper = mount(SigninPage, options);
// const vm = wrapper.vm;
});
});