Skip to content

Commit 52961f0

Browse files
committed
Opti tests, no need preview when page not requested.
1 parent de8acd4 commit 52961f0

File tree

10 files changed

+16
-38
lines changed

10 files changed

+16
-38
lines changed

packages/addons/_tests/_setup/suite.ts

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

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

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

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

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

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

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

@@ -26,25 +27,3 @@ test.concurrent.for(variants)('default - %s', async (variant, { page, ...ctx })
2627
// Check if it's called
2728
expect(viteContent).toContain(`devtoolsJson()`);
2829
});
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 });
13+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
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 });
15+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
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 });
11+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
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 });
10+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
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 });
13+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
1414
// kill server process when we're done
1515
ctx.onTestFinished(async () => await close());
1616

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

Lines changed: 4 additions & 7 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 - %s', async (variant, { page, ...ctx }) => {
11+
test.concurrent.for(kitOnly)('core node - %s', async (variant, { page, ...ctx }) => {
1212
const cwd = await ctx.run(variant, { [addonId]: { adapter: 'node' } });
1313

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

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

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

27-
const { close } = await prepareServer({ cwd, page });
28-
// kill server process when we're done
29-
ctx.onTestFinished(async () => await close());
30-
27+
// Check only generated files.
3128
expect(await readFile(join(cwd, 'svelte.config.js'), 'utf8')).toMatch('adapter-auto');
3229
expect(await readFile(join(cwd, 'svelte.config.js'), 'utf8')).toMatch(
3330
'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 });
11+
const { close } = await prepareServer({ cwd, page, previewCommand: null! });
1212

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

0 commit comments

Comments
 (0)