-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
178 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
import '@testing-library/jest-dom/vitest' | ||
import { expect } from 'vitest' | ||
|
||
expect.extend({ | ||
toHaveBeenCalledBefore(received, expected) { | ||
Check failure on line 5 in tests/setup.ts GitHub Actions / test_matrix (3.9.7)
Check failure on line 5 in tests/setup.ts GitHub Actions / test_matrix (3.9.7)
Check failure on line 5 in tests/setup.ts GitHub Actions / test_matrix (4.0.5)
Check failure on line 5 in tests/setup.ts GitHub Actions / test_matrix (4.0.5)
Check failure on line 5 in tests/setup.ts GitHub Actions / test_matrix (3.8.3)
|
||
const pass = | ||
received.mock.invocationCallOrder[0] < | ||
expected.mock.invocationCallOrder[0] | ||
return { | ||
pass, | ||
message: () => | ||
`expected ${received} to have been called before ${expected}`, | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// vitest-extend.d.ts | ||
import type { SpyInstance } from 'vitest' | ||
|
||
// 1. Augment the 'vitest' module: | ||
declare module 'vitest' { | ||
interface Assertion<T = any> { | ||
/** | ||
* Custom matcher that asserts that one mock was called before another. | ||
* Usage: | ||
* expect(mockA).toHaveBeenCalledBefore(mockB) | ||
*/ | ||
toHaveBeenCalledBefore(expected: SpyInstance): void | ||
} | ||
} |