mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
512a245f13
The webServer configuration in @playwright/test now accepts a url as an alternative to a port number to wait for a url to return a 2xx status code.
16 lines
469 B
JavaScript
16 lines
469 B
JavaScript
const { TestServer } = require('../../../utils/testserver/');
|
|
TestServer.create(__dirname, process.argv[2] || 3000).then(server => {
|
|
console.log('listening on port', server.PORT);
|
|
let ready = false;
|
|
setTimeout(() => ready = true, 750);
|
|
server.setRoute('/ready', (message, response) => {
|
|
if (ready) {
|
|
response.statusCode = 200;
|
|
response.end('hello');
|
|
} else {
|
|
response.statusCode = 404;
|
|
response.end('not-ready');
|
|
}
|
|
});
|
|
});
|