mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(server): consider 3XX, 400-403 responses as started server
This commit is contained in:
parent
7c0bff15ca
commit
30f3d526eb
@ -153,7 +153,7 @@ async function isURLAvailable(url: URL, ignoreHTTPSErrors: boolean, onStdErr: Re
|
||||
indexUrl.pathname = '/index.html';
|
||||
statusCode = await httpStatusCode(indexUrl, ignoreHTTPSErrors, onStdErr);
|
||||
}
|
||||
return statusCode >= 200 && statusCode < 300;
|
||||
return statusCode >= 200 && statusCode < 404;
|
||||
}
|
||||
|
||||
async function httpStatusCode(url: URL, ignoreHTTPSErrors: boolean, onStdErr: Reporter['onStdErr']): Promise<number> {
|
||||
|
@ -13,5 +13,9 @@ setTimeout(() => {
|
||||
server.setRoute('/port', (_, response) => {
|
||||
response.end('' + server.PORT);
|
||||
});
|
||||
server.setRoute('/redirect', (_, response) => {
|
||||
response.writeHead(301, 'Moved');
|
||||
response.end();
|
||||
});
|
||||
});
|
||||
}, process.argv[3] ? +process.argv[3] : 0);
|
||||
|
@ -546,3 +546,26 @@ test.describe('baseURL with plugins', () => {
|
||||
expect(result.passed).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
test('should treat 3XX as available server', async ({ runInlineTest }, { workerIndex }) => {
|
||||
const port = workerIndex + 10500;
|
||||
const result = await runInlineTest({
|
||||
'test.spec.ts': `
|
||||
const { test } = pwt;
|
||||
test('pass', async ({}) => {});
|
||||
`,
|
||||
'playwright.config.ts': `
|
||||
module.exports = {
|
||||
webServer: {
|
||||
command: 'node ${JSON.stringify(SIMPLE_SERVER_PATH)} ${port}',
|
||||
url: 'http://localhost:${port}/redirect',
|
||||
}
|
||||
};
|
||||
`,
|
||||
}, {}, { DEBUG: 'pw:webserver' });
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.output).toContain('[WebServer] listening');
|
||||
expect(result.output).toContain('[WebServer] error from server');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user