Skip to content

Commit 167fdbd

Browse files
committed
add dummy flavor
1 parent 1db5b78 commit 167fdbd

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

packages/addons/_tests/_setup/suite.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const variants = vitest.inject('variants');
1919
type Fixtures<Addons extends AddonMap> = {
2020
page: Page;
2121
run(variant: ProjectVariant, options: OptionMap<Addons>): Promise<string>;
22-
cwdVariant: (variant: ProjectVariant) => string;
22+
cwdVariant: (flavor: string, variant: ProjectVariant) => string;
2323
};
2424

2525
const installAddonHelper = async <Addons extends AddonMap>(
@@ -44,7 +44,10 @@ const installAddonHelper = async <Addons extends AddonMap>(
4444

4545
export function setupTest<Addons extends AddonMap>(
4646
addons: Addons,
47-
options?: { skipBrowser?: boolean; runPrepareAndInstallWithOption?: OptionMap<Addons> }
47+
options?: {
48+
skipBrowser?: boolean;
49+
runPrepareAndInstallWithOption?: Record<string, OptionMap<Addons>>;
50+
}
4851
) {
4952
const test = vitest.test.extend<Fixtures<Addons>>({} as any);
5053

@@ -92,8 +95,10 @@ export function setupTest<Addons extends AddonMap>(
9295
if (options?.runPrepareAndInstallWithOption) {
9396
// prepare: run addon for all variants
9497
for (const variant of variants) {
95-
const cwd = create({ testId: variant, variant });
96-
await installAddonHelper(cwd, addons, variant, options.runPrepareAndInstallWithOption);
98+
for (const [key, value] of Object.entries(options.runPrepareAndInstallWithOption)) {
99+
const cwd = create({ testId: key + '_' + variant, variant });
100+
await installAddonHelper(cwd, addons, variant, value);
101+
}
97102
}
98103

99104
// install: run pnpm install
@@ -108,11 +113,11 @@ export function setupTest<Addons extends AddonMap>(
108113
browserCtx = await browser.newContext();
109114
ctx.page = await browserCtx.newPage();
110115
}
111-
ctx.cwdVariant = (variant) => {
112-
return path.resolve(cwdTestName, variant);
116+
ctx.cwdVariant = (flavor, variant) => {
117+
return path.resolve(cwdTestName, `${flavor}_${variant}`);
113118
};
114119
ctx.run = async (variant, runOptions) => {
115-
const cwd = create({ testId: variant, variant });
120+
const cwd = create({ testId: ctx.task.id, variant });
116121
await installAddonHelper(cwd, addons, variant, runOptions);
117122
return cwd;
118123
};

packages/addons/_tests/devtools-json/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ const { test, variants, prepareServer } = setupTest(
88
{ devtoolsJson },
99
{
1010
skipBrowser: true,
11-
runPrepareAndInstallWithOption: { devtoolsJson: {} }
11+
runPrepareAndInstallWithOption: { default: { devtoolsJson: {} } }
1212
}
1313
);
1414

1515
test.concurrent.for(variants)('default - %s', async (variant, { page, ...ctx }) => {
16-
const cwd = ctx.cwdVariant(variant);
16+
const cwd = ctx.cwdVariant('default', variant);
1717

1818
const { close } = await prepareServer({ cwd, page, installCommand: null! });
1919
// kill server process when we're done

packages/cli/lib/testing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export function createProject({ cwd, testName, templatesDir }: CreateOptions): C
7070
// create the reference dir
7171
const testDir = path.resolve(cwd, testName);
7272
fs.mkdirSync(testDir, { recursive: true });
73-
return ({ variant, clean = true }) => {
74-
const targetDir = path.resolve(testDir, variant);
73+
return ({ testId, variant, clean = true }) => {
74+
const targetDir = path.resolve(testDir, testId);
7575
if (clean && fs.existsSync(targetDir)) {
7676
fs.rmSync(targetDir, { force: true, recursive: true });
7777
}

0 commit comments

Comments
 (0)