chore: move TestServer under test/ (#23287)
This commit is contained in:
Родитель
4a9723df48
Коммит
00b34dddb2
|
@ -17,7 +17,7 @@
|
|||
import type { Fixtures } from '@playwright/test';
|
||||
import path from 'path';
|
||||
import socks from 'socksv5';
|
||||
import { TestServer } from '../../utils/testserver';
|
||||
import { TestServer } from './testserver';
|
||||
import { TestProxy } from './proxy';
|
||||
|
||||
export type ServerWorkerOptions = {
|
||||
|
|
|
@ -672,8 +672,8 @@ it('should contain http2 for http2 requests', async ({ contextFactory, browserNa
|
|||
it.fixme(browserName === 'webkit' && platform === 'win32');
|
||||
|
||||
const server = http2.createSecureServer({
|
||||
key: await fs.promises.readFile(path.join(__dirname, '..', '..', 'utils', 'testserver', 'key.pem')),
|
||||
cert: await fs.promises.readFile(path.join(__dirname, '..', '..', 'utils', 'testserver', 'cert.pem')),
|
||||
key: await fs.promises.readFile(path.join(__dirname, '..', 'config', 'testserver', 'key.pem')),
|
||||
cert: await fs.promises.readFile(path.join(__dirname, '..', 'config', 'testserver', 'cert.pem')),
|
||||
});
|
||||
server.on('stream', stream => {
|
||||
stream.respond({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { TestServer } from '../../utils/testserver';
|
||||
import type { TestServer } from '../config/testserver';
|
||||
import { test as it, expect } from './pageTest';
|
||||
|
||||
function initServer(server: TestServer): string[] {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import { test as it, expect } from './pageTest';
|
||||
import type { Frame } from 'playwright-core';
|
||||
import type { TestServer } from '../../utils/testserver';
|
||||
import type { TestServer } from '../config/testserver';
|
||||
|
||||
it('should navigate to empty page with networkidle', async ({ page, server }) => {
|
||||
const response = await page.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' });
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
const { TestServer } = require('../../../utils/testserver/');
|
||||
// delay creating the server to test waiting for it
|
||||
setTimeout(() => {
|
||||
TestServer.create(__dirname, process.argv[2] || 3000).then(server => {
|
||||
console.log(`Listening on http://localhost:${server.PORT}`);
|
||||
server.setRoute('/hello', (message, response) => {
|
||||
response.end('hello');
|
||||
});
|
||||
});
|
||||
}, 750);
|
|
@ -1,18 +0,0 @@
|
|||
# TestServer
|
||||
|
||||
This test server is used internally by Playwright to test Playwright itself.
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
const {TestServer} = require('.');
|
||||
|
||||
(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!');
|
||||
})();
|
||||
```
|
|
@ -1,34 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
const {TestServer} = require('.');
|
||||
|
||||
const port = 8907;
|
||||
const httpsPort = 8908;
|
||||
const assetsPath = path.join(__dirname, '../../tests/assets');
|
||||
const cachedPath = path.join(__dirname, '../../tests/assets/cached');
|
||||
|
||||
Promise.all([
|
||||
TestServer.create(assetsPath, port),
|
||||
TestServer.createHTTPS(assetsPath, httpsPort)
|
||||
]).then(([server, httpsServer]) => {
|
||||
server.enableHTTPCache(cachedPath);
|
||||
httpsServer.enableHTTPCache(cachedPath);
|
||||
console.log(`HTTP: server is running on http://localhost:${port}`);
|
||||
console.log(`HTTPS: server is running on https://localhost:${httpsPort}`);
|
||||
});
|
Загрузка…
Ссылка в новой задаче