2018-09-24 19:46:39 +00:00
|
|
|
# TestServer
|
|
|
|
|
|
|
|
This test server is used internally by Puppeteer to test Puppeteer itself.
|
|
|
|
|
|
|
|
### Example
|
|
|
|
|
2022-07-01 11:52:39 +00:00
|
|
|
```ts
|
2018-09-24 19:46:39 +00:00
|
|
|
const {TestServer} = require('@pptr/testserver');
|
|
|
|
|
|
|
|
(async(() => {
|
|
|
|
const httpServer = await TestServer.create(__dirname, 8000),
|
|
|
|
const httpsServer = await TestServer.createHTTPS(__dirname, 8001)
|
|
|
|
httpServer.setRoute('/hello', (req, res) => {
|
|
|
|
res.end('Hello, world!');
|
|
|
|
});
|
|
|
|
console.log('HTTP and HTTPS servers are running!');
|
|
|
|
})();
|
|
|
|
```
|