Skip to content

Commit bf45bf9

Browse files
committed
improvements
1 parent af34b58 commit bf45bf9

File tree

4 files changed

+17
-26
lines changed

4 files changed

+17
-26
lines changed

packages/adder-tests/common.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { getAdderDetails, officialAdders } from '@sveltejs/adders';
2+
3+
export async function getAdderTestDetails() {
4+
return Promise.all(
5+
officialAdders.map(async (x) => {
6+
return {
7+
config: getAdderDetails(x.id),
8+
tests: (await import(`../adders/${x.id}/tests.ts`)).tests
9+
};
10+
})
11+
);
12+
}
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import { test, describe, beforeAll, afterAll } from 'vitest';
2-
import { getAdderDetails, getAdderTestDetails, officialAdders } from '@sveltejs/adders';
2+
import { getAdderTestDetails } from '../../common.ts';
33
import { runEndToEndTests } from '@sveltejs/adder-testing-library';
44

5-
// todo: I'm sure there is a better way to do this
6-
const adders = await Promise.all(
7-
officialAdders.map(async (x) => {
8-
return {
9-
config: getAdderDetails(x.id),
10-
tests: await getAdderTestDetails(x.id)
11-
};
12-
})
13-
);
5+
const adders = await getAdderTestDetails();
146

157
runEndToEndTests('.outputs-e2e', adders, describe, test.concurrent, beforeAll, afterAll);

packages/adder-tests/tests/official/snapshots.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import { test, describe, beforeAll, afterAll } from 'vitest';
2-
import { getAdderTestDetails, getAdderDetails, officialAdders } from '@sveltejs/adders';
32
import { runSnapshotTests } from '@sveltejs/adder-testing-library';
3+
import { getAdderTestDetails } from '../../common.ts';
44

5-
// todo: I'm sure there is a better way to do this
6-
const adders = await Promise.all(
7-
officialAdders.map(async (x) => {
8-
return {
9-
config: getAdderDetails(x.id),
10-
tests: await getAdderTestDetails(x.id)
11-
};
12-
})
13-
);
5+
const adders = await getAdderTestDetails();
146

157
runSnapshotTests(
168
'.outputs-snapshots',

packages/adders/_config/official.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AdderTestConfig, AdderWithoutExplicitArgs } from '@sveltejs/cli-core';
1+
import type { AdderWithoutExplicitArgs } from '@sveltejs/cli-core';
22

33
import drizzle from '../drizzle/index.ts';
44
import eslint from '../eslint/index.ts';
@@ -36,8 +36,3 @@ export function getAdderDetails(id: string): AdderWithoutExplicitArgs {
3636

3737
return details as AdderWithoutExplicitArgs;
3838
}
39-
40-
export async function getAdderTestDetails(id: string) {
41-
const defaultAA = await import(`../${id}/tests.ts`);
42-
return defaultAA.tests as AdderTestConfig<Record<string, any>>;
43-
}

0 commit comments

Comments
 (0)