mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
22 lines
753 B
JavaScript
22 lines
753 B
JavaScript
const { TestServer } = require('../../../utils/testserver/');
|
|
console.error('error from server');
|
|
// delay creating the server to test waiting for it
|
|
setTimeout(() => {
|
|
TestServer.create(__dirname, process.argv[2] || 3000).then(server => {
|
|
console.log('listening on port', server.PORT);
|
|
server.setRoute('/hello', (message, response) => {
|
|
response.end('hello');
|
|
});
|
|
server.setRoute('/env-FOO', (message, response) => {
|
|
response.end(process.env.FOO);
|
|
});
|
|
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);
|