mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat: various docker integration improvements (#9988)
- shorter docker terminal message - terminate testrunner if docker cannot be found - use `-docker` suffix for snapshots / screenshots.
This commit is contained in:
parent
06cf7132be
commit
62a01a41c6
@ -28,8 +28,7 @@ const dockerFactory: GridFactory = {
|
||||
const { vncUrl } = await launchDockerGridAgent(options.agentId, options.gridURL);
|
||||
/* eslint-disable no-console */
|
||||
console.log(``);
|
||||
console.log(`✨ Running browsers inside docker container ✨`);
|
||||
console.log(`- look inside: ${vncUrl}`);
|
||||
console.log(`✨ Running browsers inside docker container: ${vncUrl} ✨`);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -285,12 +285,12 @@ export class GridServer {
|
||||
});
|
||||
}
|
||||
|
||||
public async createAgent() {
|
||||
public async createAgent(): Promise<{ error: any }> {
|
||||
const { initPromise } = this._createAgent();
|
||||
await initPromise;
|
||||
return await initPromise;
|
||||
}
|
||||
|
||||
private _createAgent(): {agent: GridAgent, initPromise: Promise<{success: boolean, error: any}>} {
|
||||
private _createAgent(): {agent: GridAgent, initPromise: Promise<{ error: any }>} {
|
||||
const agent = new GridAgent(this._factory.capacity, this._factory.launchTimeout, this._factory.retireTimeout);
|
||||
this._agents.set(agent.agentId, agent);
|
||||
agent.on('close', () => {
|
||||
@ -303,12 +303,12 @@ export class GridServer {
|
||||
playwrightVersion: getPlaywrightVersion(),
|
||||
})).then(() => {
|
||||
this._log('created');
|
||||
return { success: true, error: undefined };
|
||||
return { error: undefined };
|
||||
}).catch(error => {
|
||||
this._log('failed to launch agent ' + agent.agentId);
|
||||
console.error(error);
|
||||
agent.closeAgent(WSErrors.AGENT_CREATION_FAILED);
|
||||
return { success: false, error };
|
||||
return { error };
|
||||
});
|
||||
return { agent, initPromise };
|
||||
}
|
||||
|
@ -232,7 +232,9 @@ async function launchDockerContainer(): Promise<() => Promise<void>> {
|
||||
const gridServer = new GridServer(dockerFactory, createGuid());
|
||||
await gridServer.start();
|
||||
// Start docker container in advance.
|
||||
await gridServer.createAgent();
|
||||
const { error } = await gridServer.createAgent();
|
||||
if (error)
|
||||
throw error;
|
||||
process.env.PW_GRID = gridServer.urlPrefix().substring(0, gridServer.urlPrefix().length - 1);
|
||||
return async () => await gridServer.stop();
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ export const test = _baseTest.extend<TestFixtures, WorkerAndFileFixtures>({
|
||||
});
|
||||
},
|
||||
|
||||
_snapshotSuffix: [process.platform, { scope: 'worker' }],
|
||||
_snapshotSuffix: [process.env.PLAYWRIGHT_DOCKER ? 'docker' : process.platform, { scope: 'worker' }],
|
||||
|
||||
_setupContextOptionsAndArtifacts: [async ({ _snapshotSuffix, _browserType, _combinedContextOptions, _artifactsDir, trace, screenshot, actionTimeout, navigationTimeout }, use, testInfo) => {
|
||||
testInfo.snapshotSuffix = _snapshotSuffix;
|
||||
|
Loading…
x
Reference in New Issue
Block a user