Skip to content

Commit

Permalink
fix some tests that fail locally (#5243)
Browse files Browse the repository at this point in the history
* fix some tests that fail locally

* lint
  • Loading branch information
Rich-Harris authored Jun 23, 2022
1 parent a922095 commit ddb43dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import fs from 'fs';
import path from 'path';
import http from 'http';
import * as ports from 'port-authority';
import { expect } from '@playwright/test';
import { fileURLToPath } from 'url';
import { start_server, test } from '../../../utils.js';
Expand Down Expand Up @@ -1405,12 +1403,11 @@ test.describe.parallel('Load', () => {

test('handles external api', async ({ page }) => {
await page.goto('/load');
const port = await ports.find(5000);

/** @type {string[]} */
const requested_urls = [];

const server = http.createServer(async (req, res) => {
const { port, server } = await start_server(async (req, res) => {
if (!req.url) throw new Error('Incomplete request');
requested_urls.push(req.url);

Expand All @@ -1427,10 +1424,6 @@ test.describe.parallel('Load', () => {
}
});

await new Promise((fulfil) => {
server.listen(port, () => fulfil(undefined));
});

await page.goto(`/load/server-fetch-request?port=${port}`);

expect(requested_urls).toEqual(['/server-fetch-request-modified.json']);
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export async function start_server(handler, start = 4000) {
const server = http.createServer(handler);

await new Promise((fulfil) => {
server.listen(port, () => fulfil(undefined));
server.listen(port, 'localhost', () => fulfil(undefined));
});

return { port, server };
Expand Down

0 comments on commit ddb43dc

Please sign in to comment.