Skip to content

Commit d0f2afd

Browse files
committed
[chore] test debugging improvements
1 parent 68c3906 commit d0f2afd

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

packages/kit/src/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ prog
151151
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
152152
const config = await get_config();
153153

154-
const { start } = await import('./core/start/index.js');
154+
const { preview } = await import('./core/preview/index.js');
155155

156156
try {
157-
await start({ port, host, config, https });
157+
await preview({ port, host, config, https });
158158

159159
welcome({ port, host, https, open });
160160
} catch (error) {

packages/kit/src/core/start/index.js renamed to packages/kit/src/core/preview/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ const mutable = (dir) =>
2323
* cwd?: string;
2424
* }} opts
2525
*/
26-
export async function start({ port, host, config, https: use_https = false, cwd = process.cwd() }) {
26+
export async function preview({
27+
port,
28+
host,
29+
config,
30+
https: use_https = false,
31+
cwd = process.cwd()
32+
}) {
2733
__fetch_polyfill();
2834

2935
const app_file = resolve(cwd, `${SVELTE_KIT}/output/server/app.js`);
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "test-amp",
3+
"private": true,
4+
"version": "0.0.1",
5+
"scripts": {
6+
"dev": "../../../svelte-kit.js dev",
7+
"build": "../../../svelte-kit.js build",
8+
"preview": "../../../svelte-kit.js preview"
9+
},
10+
"devDependencies": {
11+
"@sveltejs/adapter-node": "workspace:*",
12+
"@sveltejs/kit": "workspace:*",
13+
"svelte": "^3.40.0"
14+
},
15+
"type": "module"
16+
}

packages/kit/test/apps/amp/src/routes/host/_tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as assert from 'uvu/assert';
44
export default function (test) {
55
// this test lives in the AMP app because `basics` has `hostHeader`
66
// configured, and `options` has `host` configured
7-
test('sets host', '/host', async ({ base, page }) => {
7+
test('sets host amp', '/host', async ({ base, page }) => {
88
const hostname = new URL(base).host;
99
assert.equal(await page.textContent('[data-source="load"]'), hostname);
1010
assert.equal(await page.textContent('[data-source="store"]'), hostname);

packages/kit/test/apps/basics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "test/basics",
2+
"name": "test-basics",
33
"private": true,
44
"version": "0.0.1",
55
"scripts": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "test-options",
3+
"private": true,
4+
"version": "0.0.1",
5+
"scripts": {
6+
"dev": "../../../svelte-kit.js dev",
7+
"build": "../../../svelte-kit.js build",
8+
"preview": "../../../svelte-kit.js preview"
9+
},
10+
"devDependencies": {
11+
"@sveltejs/adapter-node": "workspace:*",
12+
"@sveltejs/kit": "workspace:*",
13+
"svelte": "^3.40.0"
14+
},
15+
"type": "module"
16+
}

packages/kit/test/test.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import fetch from 'node-fetch';
55
import { chromium } from 'playwright-chromium';
66
import { dev } from '../src/core/dev/index.js';
77
import { build } from '../src/core/build/index.js';
8-
import { start } from '../src/core/start/index.js';
8+
import { preview } from '../src/core/preview/index.js';
99
import { load_config } from '../src/core/config/index.js';
1010
import { fileURLToPath, pathToFileURL } from 'url';
1111
import { format } from 'util';
@@ -17,7 +17,7 @@ import { format } from 'util';
1717
async function setup({ port }) {
1818
const base = `http://localhost:${port}`;
1919

20-
const browser = await chromium.launch();
20+
const browser = await chromium.launch({ headless: true });
2121

2222
const contexts = {
2323
js: await browser.newContext({ javaScriptEnabled: true }),
@@ -165,10 +165,11 @@ function duplicate(test_fn, config, is_build) {
165165
if (!dev) return;
166166
}
167167

168-
if (process.env.FILTER && !name.includes(process.env.FILTER)) return;
169-
170168
if (nojs) {
171-
test_fn(`${name} [no js]`, async (context) => {
169+
name = `${name} [no js]`;
170+
if (process.env.FILTER && !name.includes(process.env.FILTER)) return;
171+
172+
test_fn(name, async (context) => {
172173
let response;
173174

174175
if (start) {
@@ -188,7 +189,10 @@ function duplicate(test_fn, config, is_build) {
188189
}
189190

190191
if (js && !config.kit.amp) {
191-
test_fn(`${name} [js]`, async (context) => {
192+
name = `${name} [js]`;
193+
if (process.env.FILTER && !name.includes(process.env.FILTER)) return;
194+
195+
test_fn(name, async (context) => {
192196
let response;
193197

194198
if (start) {
@@ -332,7 +336,7 @@ async function main() {
332336
runtime: '../../../../../src/runtime/server/index.js'
333337
});
334338

335-
context.server = await start({ port, config, cwd, host: undefined, https: false });
339+
context.server = await preview({ port, config, cwd, host: undefined, https: false });
336340
Object.assign(context, await setup({ port }));
337341
} catch (e) {
338342
// the try-catch is necessary pending https://github.com./lukeed/uvu/issues/80

0 commit comments

Comments
 (0)