chore: use --parallel (#8612)
This commit is contained in:
parent
45eb2c607f
commit
28e236f1a6
@ -51,7 +51,6 @@ describe('Cookie specs', () => {
|
|||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
secure: false,
|
secure: false,
|
||||||
session: true,
|
session: true,
|
||||||
sourcePort: 8907,
|
|
||||||
sourceScheme: 'NonSecure',
|
sourceScheme: 'NonSecure',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@ -112,7 +111,6 @@ describe('Cookie specs', () => {
|
|||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
secure: false,
|
secure: false,
|
||||||
session: true,
|
session: true,
|
||||||
sourcePort: 8907,
|
|
||||||
sourceScheme: 'NonSecure',
|
sourceScheme: 'NonSecure',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -126,7 +124,6 @@ describe('Cookie specs', () => {
|
|||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
secure: false,
|
secure: false,
|
||||||
session: true,
|
session: true,
|
||||||
sourcePort: 8907,
|
|
||||||
sourceScheme: 'NonSecure',
|
sourceScheme: 'NonSecure',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -128,7 +128,7 @@ describe('Coverage specs', function () {
|
|||||||
await page.goto(server.PREFIX + '/jscoverage/involved.html');
|
await page.goto(server.PREFIX + '/jscoverage/involved.html');
|
||||||
const coverage = await page.coverage.stopJSCoverage();
|
const coverage = await page.coverage.stopJSCoverage();
|
||||||
expect(
|
expect(
|
||||||
JSON.stringify(coverage, null, 2).replace(/:\d{4}\//g, ':<PORT>/')
|
JSON.stringify(coverage, null, 2).replace(/:\d{4,5}\//g, ':<PORT>/')
|
||||||
).toBeGolden('jscoverage-involved.txt');
|
).toBeGolden('jscoverage-involved.txt');
|
||||||
});
|
});
|
||||||
// @see https://crbug.com/990945
|
// @see https://crbug.com/990945
|
||||||
@ -267,7 +267,7 @@ describe('Coverage specs', function () {
|
|||||||
await page.goto(server.PREFIX + '/csscoverage/involved.html');
|
await page.goto(server.PREFIX + '/csscoverage/involved.html');
|
||||||
const coverage = await page.coverage.stopCSSCoverage();
|
const coverage = await page.coverage.stopCSSCoverage();
|
||||||
expect(
|
expect(
|
||||||
JSON.stringify(coverage, null, 2).replace(/:\d{4}\//g, ':<PORT>/')
|
JSON.stringify(coverage, null, 2).replace(/:\d{4,5}\//g, ':<PORT>/')
|
||||||
).toBeGolden('csscoverage-involved.txt');
|
).toBeGolden('csscoverage-involved.txt');
|
||||||
});
|
});
|
||||||
it('should work with empty stylesheets', async () => {
|
it('should work with empty stylesheets', async () => {
|
||||||
|
@ -44,7 +44,6 @@ describe('DefaultBrowserContext', function () {
|
|||||||
httpOnly: false,
|
httpOnly: false,
|
||||||
secure: false,
|
secure: false,
|
||||||
session: true,
|
session: true,
|
||||||
sourcePort: 8907,
|
|
||||||
sourceScheme: 'NonSecure',
|
sourceScheme: 'NonSecure',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import diff from 'diff';
|
import {diffLines} from 'diff';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import jpeg from 'jpeg-js';
|
import jpeg from 'jpeg-js';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
@ -90,7 +90,7 @@ const compareText = (
|
|||||||
if (expected === actual) {
|
if (expected === actual) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = diff.diffLines(expected, actual);
|
const result = diffLines(expected, actual);
|
||||||
const html = result.reduce((text, change) => {
|
const html = result.reduce((text, change) => {
|
||||||
text += change.added
|
text += change.added
|
||||||
? `<span class='ins'>${change.value}</span>`
|
? `<span class='ins'>${change.value}</span>`
|
||||||
|
@ -39,16 +39,16 @@ const setupServer = async () => {
|
|||||||
const assetsPath = path.join(__dirname, '../assets');
|
const assetsPath = path.join(__dirname, '../assets');
|
||||||
const cachedPath = path.join(__dirname, '../assets', 'cached');
|
const cachedPath = path.join(__dirname, '../assets', 'cached');
|
||||||
|
|
||||||
const port = 8907;
|
const server = await TestServer.create(assetsPath);
|
||||||
const server = await TestServer.create(assetsPath, port);
|
const port = server.port;
|
||||||
server.enableHTTPCache(cachedPath);
|
server.enableHTTPCache(cachedPath);
|
||||||
server.PORT = port;
|
server.PORT = port;
|
||||||
server.PREFIX = `http://localhost:${port}`;
|
server.PREFIX = `http://localhost:${port}`;
|
||||||
server.CROSS_PROCESS_PREFIX = `http://127.0.0.1:${port}`;
|
server.CROSS_PROCESS_PREFIX = `http://127.0.0.1:${port}`;
|
||||||
server.EMPTY_PAGE = `http://localhost:${port}/empty.html`;
|
server.EMPTY_PAGE = `http://localhost:${port}/empty.html`;
|
||||||
|
|
||||||
const httpsPort = port + 1;
|
const httpsServer = await TestServer.createHTTPS(assetsPath);
|
||||||
const httpsServer = await TestServer.createHTTPS(assetsPath, httpsPort);
|
const httpsPort = httpsServer.port;
|
||||||
httpsServer.enableHTTPCache(cachedPath);
|
httpsServer.enableHTTPCache(cachedPath);
|
||||||
httpsServer.PORT = httpsPort;
|
httpsServer.PORT = httpsPort;
|
||||||
httpsServer.PREFIX = `https://localhost:${httpsPort}`;
|
httpsServer.PREFIX = `https://localhost:${httpsPort}`;
|
||||||
@ -261,14 +261,16 @@ export const describeChromeOnly = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(
|
if (process.env['MOCHA_WORKER_ID'] === '0') {
|
||||||
`Running unit tests with:
|
console.log(
|
||||||
|
`Running unit tests with:
|
||||||
-> product: ${product}
|
-> product: ${product}
|
||||||
-> binary: ${
|
-> binary: ${
|
||||||
defaultBrowserOptions.executablePath ||
|
defaultBrowserOptions.executablePath ||
|
||||||
path.relative(process.cwd(), puppeteer.executablePath())
|
path.relative(process.cwd(), puppeteer.executablePath())
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
process.on('unhandledRejection', reason => {
|
process.on('unhandledRejection', reason => {
|
||||||
throw reason;
|
throw reason;
|
||||||
@ -357,7 +359,10 @@ export const expectCookieEquals = (
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(cookies).toEqual(expectedCookies);
|
expect(cookies.length).toBe(expectedCookies.length);
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
expect(cookies[i]).toMatchObject(expectedCookies[i]!);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const shortWaitForArrayToHaveAtLeastNElements = async (
|
export const shortWaitForArrayToHaveAtLeastNElements = async (
|
||||||
|
@ -116,7 +116,7 @@ export const dumpFrames = (
|
|||||||
indentation?: string
|
indentation?: string
|
||||||
): Array<string> => {
|
): Array<string> => {
|
||||||
indentation = indentation || '';
|
indentation = indentation || '';
|
||||||
let description = frame.url().replace(/:\d{4}\//, ':<PORT>/');
|
let description = frame.url().replace(/:\d{4,5}\//, ':<PORT>/');
|
||||||
if (frame.name()) {
|
if (frame.name()) {
|
||||||
description += ' (' + frame.name() + ')';
|
description += ' (' + frame.name() + ')';
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
ServerOptions as HttpsServerOptions,
|
ServerOptions as HttpsServerOptions,
|
||||||
} from 'https';
|
} from 'https';
|
||||||
import {getType as getMimeType} from 'mime';
|
import {getType as getMimeType} from 'mime';
|
||||||
|
import {AddressInfo} from 'net';
|
||||||
import {join} from 'path';
|
import {join} from 'path';
|
||||||
import {Duplex} from 'stream';
|
import {Duplex} from 'stream';
|
||||||
import {Server as WebSocketServer, WebSocket} from 'ws';
|
import {Server as WebSocketServer, WebSocket} from 'ws';
|
||||||
@ -65,27 +66,35 @@ export class TestServer {
|
|||||||
#gzipRoutes = new Set<string>();
|
#gzipRoutes = new Set<string>();
|
||||||
#requestSubscribers = new Map<string, Subscriber>();
|
#requestSubscribers = new Map<string, Subscriber>();
|
||||||
|
|
||||||
static async create(dirPath: string, port: number): Promise<TestServer> {
|
static async create(dirPath: string): Promise<TestServer> {
|
||||||
const server = new TestServer(dirPath, port);
|
let res!: (value: unknown) => void;
|
||||||
await new Promise(x => {
|
const promise = new Promise(resolve => {
|
||||||
return server.#server.once('listening', x);
|
res = resolve;
|
||||||
});
|
});
|
||||||
|
const server = new TestServer(dirPath);
|
||||||
|
server.#server.once('listening', res);
|
||||||
|
server.#server.listen(0);
|
||||||
|
await promise;
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async createHTTPS(dirPath: string, port: number): Promise<TestServer> {
|
static async createHTTPS(dirPath: string): Promise<TestServer> {
|
||||||
const server = new TestServer(dirPath, port, {
|
let res!: (value: unknown) => void;
|
||||||
|
const promise = new Promise(resolve => {
|
||||||
|
res = resolve;
|
||||||
|
});
|
||||||
|
const server = new TestServer(dirPath, {
|
||||||
key: readFileSync(join(__dirname, '..', 'key.pem')),
|
key: readFileSync(join(__dirname, '..', 'key.pem')),
|
||||||
cert: readFileSync(join(__dirname, '..', 'cert.pem')),
|
cert: readFileSync(join(__dirname, '..', 'cert.pem')),
|
||||||
passphrase: 'aaaa',
|
passphrase: 'aaaa',
|
||||||
});
|
});
|
||||||
await new Promise(x => {
|
server.#server.once('listening', res);
|
||||||
return server.#server.once('listening', x);
|
server.#server.listen(0);
|
||||||
});
|
await promise;
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(dirPath: string, port: number, sslOptions?: HttpsServerOptions) {
|
constructor(dirPath: string, sslOptions?: HttpsServerOptions) {
|
||||||
this.#dirPath = dirPath;
|
this.#dirPath = dirPath;
|
||||||
|
|
||||||
if (sslOptions) {
|
if (sslOptions) {
|
||||||
@ -96,7 +105,6 @@ export class TestServer {
|
|||||||
this.#server.on('connection', this.#onServerConnection);
|
this.#server.on('connection', this.#onServerConnection);
|
||||||
this.#wsServer = new WebSocketServer({server: this.#server});
|
this.#wsServer = new WebSocketServer({server: this.#server});
|
||||||
this.#wsServer.on('connection', this.#onWebSocketConnection);
|
this.#wsServer.on('connection', this.#onWebSocketConnection);
|
||||||
this.#server.listen(port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#onServerConnection = (connection: Duplex): void => {
|
#onServerConnection = (connection: Duplex): void => {
|
||||||
@ -113,6 +121,10 @@ export class TestServer {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
get port(): number {
|
||||||
|
return (this.#server.address() as AddressInfo).port;
|
||||||
|
}
|
||||||
|
|
||||||
enableHTTPCache(pathPrefix: string): void {
|
enableHTTPCache(pathPrefix: string): void {
|
||||||
this.#cachedPathPrefix = pathPrefix;
|
this.#cachedPathPrefix = pathPrefix;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user