Skip to content

[Feature] Dry run mode for install-deps #10232

Description

@jawnsy

When running Playwright tests in a containerized environment, it is helpful to build a custom image with native dependencies preinstalled. It is possible to do this by manually examining the list of dependencies in the nativeDeps.ts file:

'ubuntu20.04': {
tools: [
'xvfb',
'fonts-noto-color-emoji',
'ttf-unifont',
'libfontconfig',
'libfreetype6',
'xfonts-cyrillic',
'xfonts-scalable',
'fonts-liberation',
'fonts-ipafont-gothic',
'fonts-wqy-zenhei',
'fonts-tlwg-loma-otf',
'ttf-ubuntu-font-family',
],

However, it would be convenient if there were a way to list all the dependencies that playwright would install, without actually running the install command. It looks like we can do this by separating the dependency list generation and installation commands, for example, create a function that returns uniqueLibraries and a separate function that accepts that as input, then spawns apt-get:

export async function installDependenciesLinux(targets: Set<DependencyGroup>) {
const libraries: string[] = [];
for (const target of targets) {
const info = deps[utils.hostPlatform];
if (!info) {
console.warn('Cannot install dependencies for this linux distribution!'); // eslint-disable-line no-console
return;
}
libraries.push(...info[target]);
}
const uniqueLibraries = Array.from(new Set(libraries));
console.log('Installing Ubuntu dependencies...'); // eslint-disable-line no-console
const commands: string[] = [];
commands.push('apt-get update');
commands.push(['apt-get', 'install', '-y', '--no-install-recommends',
...uniqueLibraries,
].join(' '));
const [command, args] = await buildAptProcessArgs(commands);
const child = childProcess.spawn(command, args, { stdio: 'inherit' });
await new Promise((resolve, reject) => {
child.on('exit', resolve);
child.on('error', reject);
});
}

I'd be happy to create a pull request if this is a feature you'd consider! I'd propose something like npx playwright install-deps --dry-run to return the package list for the current system

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions