-
Notifications
You must be signed in to change notification settings - Fork 666
Closed
Description
Subject of the issue
When using enableAutoUnmount(afterEach);
I am expecting the onUnmounted
hook to be called after every test, but this is not happening.
Steps to reproduce
import { enableAutoUnmount, mount } from "@vue/test-utils";
import { afterEach } from "node:test";
import { describe, it, expect } from "vitest";
import { defineComponent, onMounted, onUnmounted } from "vue";
const template = "<div>Test</div>";
const TestComponent = defineComponent({
setup() {
onMounted(() => console.log("MOUNTED"));
onUnmounted(() => console.log("UNMOUNTED"));
},
template,
});
describe("Test", () => {
enableAutoUnmount(afterEach);
for (const i of [1, 2, 3]) {
it(`test ${i}`, () => {
const wrapper = mount(TestComponent);
expect(wrapper.html()).toEqual(template);
});
}
});
Expected behaviour
Expecting to see "UNMOUNTED" logged 3 times.
Actual behaviour
TAP version 13
stdout | src/Test.test.ts > Test > test 1
MOUNTED
stdout | src/Test.test.ts > Test > test 2
MOUNTED
stdout | src/Test.test.ts > Test > test 3
MOUNTED
✓ src/Test.test.ts (3 tests) 22ms
✓ Test > test 1 17ms
✓ Test > test 2 2ms
✓ Test > test 3 2ms
Test Files 1 passed (1)
Tests 3 passed (3)
Start at 15:39:50
Duration 121ms
Package versions
- "vue": "^3.5.17",
- "@vue/test-utils": "^2.4.6",
Metadata
Metadata
Assignees
Labels
No labels