fix(test-runner): fix, linter and formatting

This commit is contained in:
Mathias Leppich 2024-10-11 16:45:50 +02:00
parent a457d169eb
commit 44fafba3f2
3 changed files with 37 additions and 9 deletions

View file

@ -223,7 +223,7 @@ async function filterTestGroups(config: FullConfigInternal, testGroups: TestGrou
const result = filter.filterTestGroups.call(filterThis, filteredTestGroups);
filteredTestGroups = result instanceof Promise ? await result : result;
} else if ('filterTests' in filter) {
const result = filter.filterTests.call(filterThis, filteredTestGroups.flatMap(group => group.tests), config.config);
const result = filter.filterTests.call(filterThis, filteredTestGroups.flatMap(group => group.tests));
const filteredTests = result instanceof Promise ? await result : result;
if (!Array.isArray(filteredTests))
throw new Error('Invalid filter result: tests should be an array');

View file

@ -1904,10 +1904,24 @@ export type TestDetails = {
annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];
}
type TestFilterThis = { config: FullConfig };
type TestFilterFunction = (this: TestFilterThis, test: TestCase) => boolean;
type TestsFilter = { filterTests(this: TestFilterThis, tests: TestCase[]): Promise<TestCase[]> | TestCase[] };
type TestGroupsFilter = { filterTestGroups(this: TestFilterThis, testGroups: { tests: TestCase[] }[]): Promise<{ tests: TestCase[] }[]> | { tests: TestCase[] }[] };
type TestFilterThis = {
config: FullConfig
}
export type TestFilterFunction = (this: TestFilterThis, test: TestCase) => boolean;
export type TestsFilter = {
filterTests(this: TestFilterThis, tests: TestCase[]): Promise<TestCase[]> | TestCase[]
}
export type TestGroup = {
tests: TestCase[]
};
export type TestGroupsFilter = {
filterTestGroups(this: TestFilterThis, testGroups: TestGroup[]): Promise<TestGroup[]> | TestGroup[]
}
export type TestFilter = TestFilterFunction | TestsFilter | TestGroupsFilter;
interface SuiteFunction {

View file

@ -77,10 +77,24 @@ export type TestDetails = {
annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];
}
type TestFilterThis = { config: FullConfig };
type TestFilterFunction = (this: TestFilterThis, test: TestCase) => boolean;
type TestsFilter = { filterTests(this: TestFilterThis, tests: TestCase[]): Promise<TestCase[]> | TestCase[] };
type TestGroupsFilter = { filterTestGroups(this: TestFilterThis, testGroups: { tests: TestCase[] }[]): Promise<{ tests: TestCase[] }[]> | { tests: TestCase[] }[] };
type TestFilterThis = {
config: FullConfig
}
export type TestFilterFunction = (this: TestFilterThis, test: TestCase) => boolean;
export type TestsFilter = {
filterTests(this: TestFilterThis, tests: TestCase[]): Promise<TestCase[]> | TestCase[]
}
export type TestGroup = {
tests: TestCase[]
};
export type TestGroupsFilter = {
filterTestGroups(this: TestFilterThis, testGroups: TestGroup[]): Promise<TestGroup[]> | TestGroup[]
}
export type TestFilter = TestFilterFunction | TestsFilter | TestGroupsFilter;
interface SuiteFunction {