Skip to content

Commit 5518f9c

Browse files
committed
Revert "Opti tests, no need preview when page not requested."
This reverts commit 52961f0.
1 parent 52961f0 commit 5518f9c

File tree

10 files changed

+38
-16
lines changed

10 files changed

+38
-16
lines changed

packages/addons/_tests/_setup/suite.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ async function prepareServer(
117117
if (buildCommand) execSync(buildCommand, { cwd, stdio: 'pipe' });
118118

119119
// start preview server
120-
if (!previewCommand) return { url: null, close: () => {} };
121-
122120
const { url, close } = await startPreview({ cwd, command: previewCommand });
123121

124122
// increases timeout as 30s is not always enough when running the full suite

packages/addons/_tests/all-addons/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const kitOnly = variants.filter((v) => v.startsWith('kit'));
2222
test.concurrent.for(kitOnly)('run all addons - %s', async (variant, { page, ...ctx }) => {
2323
const cwd = await ctx.run(variant, defaultOptions);
2424

25-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
25+
const { close } = await prepareServer({ cwd, page });
2626
// kill server process when we're done
2727
ctx.onTestFinished(async () => await close());
2828

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ const { test, variants, prepareServer } = setupTest({ devtoolsJson } as {
88
devtoolsJson?: typeof devtoolsJson;
99
});
1010

11-
const kitOnly = variants.filter((v) => v.includes('kit'));
12-
test.concurrent.for(kitOnly)('default - %s', async (variant, { page, ...ctx }) => {
11+
test.concurrent.for(variants)('default - %s', async (variant, { page, ...ctx }) => {
1312
const cwd = await ctx.run(variant, { devtoolsJson: {} });
1413

15-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
14+
const { close } = await prepareServer({ cwd, page });
1615
// kill server process when we're done
1716
ctx.onTestFinished(async () => await close());
1817

@@ -27,3 +26,25 @@ test.concurrent.for(kitOnly)('default - %s', async (variant, { page, ...ctx }) =
2726
// Check if it's called
2827
expect(viteContent).toContain(`devtoolsJson()`);
2928
});
29+
30+
test.concurrent.for(variants)(
31+
'without selecting the addon specifically - %s',
32+
async (variant, { page, ...ctx }) => {
33+
const cwd = await ctx.run(variant, {});
34+
35+
const { close } = await prepareServer({ cwd, page });
36+
// kill server process when we're done
37+
ctx.onTestFinished(async () => await close());
38+
39+
const ext = variant.includes('ts') ? 'ts' : 'js';
40+
const viteFile = path.resolve(cwd, `vite.config.${ext}`);
41+
const viteContent = fs.readFileSync(viteFile, 'utf8');
42+
43+
// Check if we have the import part
44+
expect(viteContent).toContain(`import devtoolsJson from`);
45+
expect(viteContent).toContain(`vite-plugin-devtools-json`);
46+
47+
// Check if it's called
48+
expect(viteContent).toContain(`devtoolsJson()`);
49+
}
50+
);

packages/addons/_tests/eslint/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { test, variants, prepareServer } = setupTest({ eslint });
1010
test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) => {
1111
const cwd = await ctx.run(variant, { eslint: {} });
1212

13-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
13+
const { close } = await prepareServer({ cwd, page });
1414
// kill server process when we're done
1515
ctx.onTestFinished(async () => await close());
1616

packages/addons/_tests/lucia/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test.concurrent.for(kitOnly)('core - %s', async (variant, { page, ...ctx }) => {
1212
lucia: { demo: true }
1313
});
1414

15-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
15+
const { close } = await prepareServer({ cwd, page });
1616
// kill server process when we're done
1717
ctx.onTestFinished(async () => await close());
1818

packages/addons/_tests/paraglide/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const kitOnly = variants.filter((v) => v.includes('kit'));
88
test.concurrent.for(kitOnly)('core - %s', async (variant, { page, ...ctx }) => {
99
const cwd = await ctx.run(variant, { paraglide: { demo: true, languageTags: 'en' } });
1010

11-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
11+
const { close } = await prepareServer({ cwd, page });
1212
// kill server process when we're done
1313
ctx.onTestFinished(async () => await close());
1414

packages/addons/_tests/playwright/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { test, variants, prepareServer } = setupTest({ playwright });
77
test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) => {
88
const cwd = await ctx.run(variant, { playwright: {} });
99

10-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
10+
const { close } = await prepareServer({ cwd, page });
1111
// kill server process when we're done
1212
ctx.onTestFinished(async () => await close());
1313

packages/addons/_tests/prettier/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { test, variants, prepareServer } = setupTest({ prettier });
1010
test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) => {
1111
const cwd = await ctx.run(variant, { prettier: {} });
1212

13-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
13+
const { close } = await prepareServer({ cwd, page });
1414
// kill server process when we're done
1515
ctx.onTestFinished(async () => await close());
1616

packages/addons/_tests/sveltekit-adapter/test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const addonId = sveltekitAdapter.id;
88
const { test, variants, prepareServer } = setupTest({ [addonId]: sveltekitAdapter });
99

1010
const kitOnly = variants.filter((v) => v.includes('kit'));
11-
test.concurrent.for(kitOnly)('core node - %s', async (variant, { page, ...ctx }) => {
11+
test.concurrent.for(kitOnly)('core - %s', async (variant, { page, ...ctx }) => {
1212
const cwd = await ctx.run(variant, { [addonId]: { adapter: 'node' } });
1313

14-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
14+
const { close } = await prepareServer({ cwd, page });
1515
// kill server process when we're done
1616
ctx.onTestFinished(async () => await close());
1717

@@ -21,10 +21,13 @@ test.concurrent.for(kitOnly)('core node - %s', async (variant, { page, ...ctx })
2121
);
2222
});
2323

24-
test.concurrent.for(kitOnly)('core auto - %s', async (variant, { ...ctx }) => {
24+
test.concurrent.for(kitOnly)('core - %s', async (variant, { page, ...ctx }) => {
2525
const cwd = await ctx.run(variant, { [addonId]: { adapter: 'auto' } });
2626

27-
// Check only generated files.
27+
const { close } = await prepareServer({ cwd, page });
28+
// kill server process when we're done
29+
ctx.onTestFinished(async () => await close());
30+
2831
expect(await readFile(join(cwd, 'svelte.config.js'), 'utf8')).toMatch('adapter-auto');
2932
expect(await readFile(join(cwd, 'svelte.config.js'), 'utf8')).toMatch(
3033
'adapter-auto only supports some environments'

packages/addons/_tests/vitest/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { test, variants, prepareServer } = setupTest({ vitest });
88
test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) => {
99
const cwd = await ctx.run(variant, { vitest: {} });
1010

11-
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
11+
const { close } = await prepareServer({ cwd, page });
1212

1313
execSync('pnpm exec playwright install chromium', { cwd, stdio: 'pipe' });
1414
execSync('pnpm test', { cwd, stdio: 'pipe' });

0 commit comments

Comments
 (0)