Skip to content

Commit

Permalink
fix: support new vitest typings
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 4, 2023
1 parent bd3a7d0 commit 3dbaf08
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/vitest/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@ import { afterEach, beforeEach, expect } from 'vitest';

import { register as __register, toBeAnnounced } from '../to-be-announced';

interface ToBeAnnouncedMatchers {
interface ToBeAnnouncedMatchers<T = any> {
/**
* Assert whether given message was announced by ARIA live region.
*
* @param politenessSetting `POLITENESS_SETTING` of the announcement
*/
toBeAnnounced(politenessSetting?: Exclude<PolitenessSetting, 'off'>): void;
toBeAnnounced(politenessSetting?: Exclude<PolitenessSetting, 'off'>): T;
}

declare module '@vitest/expect' {

Check failure on line 15 in src/vitest/register.ts

View workflow job for this annotation

GitHub Actions / build (16)

Invalid module name in augmentation, module '@vitest/expect' cannot be found.

Check failure on line 15 in src/vitest/register.ts

View workflow job for this annotation

GitHub Actions / build (18)

Invalid module name in augmentation, module '@vitest/expect' cannot be found.
interface Assertion<T> extends ToBeAnnouncedMatchers<T> {}
}

// For Vitest below 0.31.x
declare global {
namespace Vi {
interface Assertion extends ToBeAnnouncedMatchers {}
interface Assertion<T> extends ToBeAnnouncedMatchers<T> {}
}
}

expect.extend({ toBeAnnounced });
(expect as any).extend({ toBeAnnounced });

/**
* Register `extend-to-be-expected` to track DOM nodes
Expand Down

0 comments on commit 3dbaf08

Please sign in to comment.