Skip to content

Commit b81df43

Browse files
committed
test(test-setup): fix custom path matchers type definitions
1 parent 13f9374 commit b81df43

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

testing/test-setup/src/lib/extend/path.matcher.d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

testing/test-setup/src/lib/extend/path.matcher.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ import type { SyncExpectationResult } from '@vitest/expect';
22
import { expect } from 'vitest';
33
import { osAgnosticPath } from '@code-pushup/test-utils';
44

5+
export type CustomPathMatchers = {
6+
toMatchPath: (path: string) => void;
7+
toStartWithPath: (path: string) => void;
8+
toContainPath: (path: string) => void;
9+
toEndWithPath: (path: string) => void;
10+
};
11+
12+
export type CustomAsymmetricPathMatchers = {
13+
/* eslint-disable @typescript-eslint/no-explicit-any */
14+
pathToMatch: (path: string) => any;
15+
pathToStartWith: (path: string) => any;
16+
pathToContain: (path: string) => any;
17+
pathToEndWith: (path: string) => any;
18+
/* eslint-enable @typescript-eslint/no-explicit-any */
19+
};
20+
521
expect.extend({
622
toMatchPath(actual: string, expected: string): SyncExpectationResult {
723
const normalizedReceived = osAgnosticPath(actual);

testing/test-setup/src/vitest.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* eslint-disable @typescript-eslint/consistent-type-definitions,@typescript-eslint/no-empty-interface */
12
import type {
23
CustomAsymmetricPathMatchers,
34
CustomPathMatchers,
4-
} from './lib/extend/path.matcher';
5+
} from './lib/extend/path.matcher.js';
56

67
declare module 'vitest' {
7-
type Assertion<T = unknown> = CustomPathMatchers<T>;
8-
type AsymmetricMatchersContaining = CustomAsymmetricPathMatchers<T>;
8+
interface Assertion extends CustomPathMatchers {}
9+
interface AsymmetricMatchersContaining extends CustomAsymmetricPathMatchers {}
910
}

testing/test-setup/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"references": [
1515
{
1616
"path": "./tsconfig.lib.json"
17+
},
18+
{
19+
"path": "./tsconfig.test.json"
1720
}
1821
]
1922
}

0 commit comments

Comments
 (0)