From 413a8937e7bc82a1c81dd215386ba8d7d5406377 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Tue, 25 Mar 2025 17:55:06 +0100 Subject: [PATCH] fix: use await in test Removes the warning: ``` stderr | tests/trigger.spec.ts > trigger > errors > throws error if options contains a target value Promise returned by `expect(actual).rejects.toThrowError(expected)` was not awaited. Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. Please remember to await the assertion. ``` --- tests/trigger.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/trigger.spec.ts b/tests/trigger.spec.ts index aac8974a1..da954928c 100644 --- a/tests/trigger.spec.ts +++ b/tests/trigger.spec.ts @@ -344,7 +344,7 @@ describe('trigger', () => { }) describe('errors', () => { - it('throws error if options contains a target value', () => { + it('throws error if options contains a target value', async () => { const expectedErrorMessage = '[vue-test-utils]: you cannot set the target value of an event. See the notes section of the docs for more details—https://vue-test-utils.vuejs.org/api/wrapper/trigger.html' @@ -356,7 +356,7 @@ describe('trigger', () => { const wrapper = mount(Component, {}) const fn = wrapper.trigger('click', { target: 'something' }) - expect(fn).rejects.toThrowError(expectedErrorMessage) + await expect(fn).rejects.toThrowError(expectedErrorMessage) expect(clickHandler).not.toHaveBeenCalled() })