Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add update snapshots settings #562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions l10n/bundle.l10n.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Wenn aktiviert, wird Playwright die Browserinstanz zwischen den Tests wiederverwenden. Dies deaktiviert die parallele Ausführung.",
"SETTINGS": "EINSTELLUNGEN",
"PROJECTS": "PROJEKTE",
"TOOLS": "WERKZEUGE",
"SETUP": "KONFIGURATION"
"SETUP": "KONFIGURATION",
"Update snapshots": "Snapshots aktualisieren"
}
6 changes: 5 additions & 1 deletion l10n/bundle.l10n.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"Stop dev server": "Arrêter le serveur de développement",
"this feature": "cette fonctionnalité",
"Toggle Playwright Configs": "Basculer les configurations Playwright",
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Si cette option est activée, Playwright réutilisera l'instance du navigateur entre les tests. Cela désactivera l'exécution parallèle."
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Si cette option est activée, Playwright réutilisera l'instance du navigateur entre les tests. Cela désactivera l'exécution parallèle.",
"SETTINGS": "PARAMÈTRES",
"PROJECTS": "PROJETS",
"SETUP": "CONFIGURATION",
"Update snapshots": "Mettre à jour les instantanés"
}
6 changes: 5 additions & 1 deletion l10n/bundle.l10n.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"Stop dev server": "Ferma dev server",
"this feature": "questo feature",
"Toggle Playwright Configs": "Attiva/disattiva Playwright Configs",
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Quando attivata, Playwright riusa l'instanza browser tra i test. Questo disattiva l'esecuzione parallela."
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "Quando attivata, Playwright riusa l'instanza browser tra i test. Questo disattiva l'esecuzione parallela.",
"SETTINGS": "IMPOSTAZIONI",
"PROJECTS": "PROGETTI",
"SETUP": "SETUP",
"Update snapshots": "Aggiorna snapshots"
}
6 changes: 5 additions & 1 deletion l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"Stop dev server": "Stop dev server",
"this feature": "this feature",
"Toggle Playwright Configs": "Toggle Playwright Configs",
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution."
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.",
"SETTINGS": "SETTINGS",
"PROJECTS": "PROJECTS",
"SETUP": "SETUP",
"Update snapshots": "Update snapshots"
}
6 changes: 5 additions & 1 deletion l10n/bundle.l10n.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"Stop dev server": "停止 dev 服务器",
"this feature": "该功能",
"Toggle Playwright Configs": "切换 Playwright 配置",
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "启用后,Playwright 将在测试之间重复使用浏览器实例。这将禁用并行执行。"
"When enabled, Playwright will reuse the browser instance between tests. This will disable parallel execution.": "启用后,Playwright 将在测试之间重复使用浏览器实例。这将禁用并行执行。",
"SETTINGS": "设置",
"PROJECTS": "项目",
"SETUP": "设置",
"Update snapshots": "更新快照"
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
"command": "pw.extension.toggle.runGlobalSetupOnEachRun",
"title": "%contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun%"
},
{
"category": "Test",
"command": "pw.extension.toggle.updateSnapshots",
"title": "%contributes.command.pw.extension.toggle.updateSnapshots%"
},
{
"category": "Test",
"command": "pw.extension.command.runGlobalSetup",
Expand Down Expand Up @@ -123,6 +128,11 @@
"type": "boolean",
"default": false,
"description": "%configuration.playwright.runGlobalSetupOnEachRun%"
},
"playwright.updateSnapshots": {
"type": "boolean",
"default": false,
"description": "%configuration.playwright.updateSnapshots%"
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions package.nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"contributes.command.pw.extension.toggle.reuseBrowser": "Wiederverwendung des Playwright Browsers umschalten",
"contributes.command.pw.extension.toggle.showTrace": "Playwright Trace Viewer umschalten",
"contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun": "Wiederverwendung des globalen Setups umschalten",
"contributes.command.pw.extension.toggle.updateSnapshots": "Snapshots aktualisieren umschalten",
"configuration.playwright.env": "Umgebungsvariablen, die an Playwright Test übergeben werden.",
"configuration.playwright.reuseBrowser": "Browser zwischen Tests anzeigen & wiederverwenden.",
"configuration.playwright.showTrace": "Trace Viewer anzeigen.",
"configuration.playwright.runGlobalSetupOnEachRun": "Globales Setup nicht wiederverwenden.",
"configuration.playwright.updateSnapshots": "Snapshots aktualisieren.",
"views.test.pw.extension.settingsView": "Playwright"
}
2 changes: 2 additions & 0 deletions package.nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"contributes.command.pw.extension.toggle.reuseBrowser": "Activer/désactiver la réutilisation du navigateur",
"contributes.command.pw.extension.toggle.showTrace": "Activer/désactiver Playwright Trace Viewer",
"contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun": "Activer/désactiver la réutilisation de la setup globale",
"contributes.command.pw.extension.toggle.updateSnapshots": "Activer/désactiver la mise à jour des instantanés",
"configuration.playwright.env": "Variables d'environnement à transmettre à Playwright Test.",
"configuration.playwright.reuseBrowser": "Afficher et réutiliser le navigateur entre les tests.",
"configuration.playwright.showTrace": "Afficher les traces avec Trace Viewer.",
"configuration.playwright.runGlobalSetupOnEachRun": "Ne pas réutiliser la setup globale.",
"configuration.playwright.updateSnapshots": "Mettre à jour les instantanés.",
"views.test.pw.extension.settingsView": "Playwright"
}
2 changes: 2 additions & 0 deletions package.nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"contributes.command.pw.extension.toggle.reuseBrowser": "Attiva/disattiva il riuso del browser Playwright",
"contributes.command.pw.extension.toggle.showTrace": "Attiva/disattiva il Trace Viewer di Playwright",
"contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun": "Attiva/disattiva il riuso del Playwright global setup",
"contributes.command.pw.extension.toggle.updateSnapshots": "Attiva/disattiva l'aggiornamento degli snapshots",
"configuration.playwright.env": "Variabili d'ambiente da passare a Playwright Test.",
"configuration.playwright.reuseBrowser": "Mostra & riusa il browser tra i test",
"configuration.playwright.showTrace": "Mostra il Trace Viewer.",
"configuration.playwright.runGlobalSetupOnEachRun": "Esegui il global setup ad ogni run.",
"configuration.playwright.updateSnapshots": "Aggiorna gli snapshots.",
"views.test.pw.extension.settingsView": "Playwright"
}
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"contributes.command.pw.extension.toggle.reuseBrowser": "Toggle Playwright browser reuse",
"contributes.command.pw.extension.toggle.showTrace": "Toggle Playwright Trace Viewer",
"contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun": "Toggle Playwright global setup reuse",
"contributes.command.pw.extension.toggle.updateSnapshots": "Toggle snapshots update",
"configuration.playwright.env": "Environment variables to pass to Playwright Test.",
"configuration.playwright.reuseBrowser": "Show & reuse browser between tests.",
"configuration.playwright.showTrace": "Show Trace Viewer.",
"configuration.playwright.runGlobalSetupOnEachRun": "Run global setup on each run.",
"configuration.playwright.updateSnapshots": "Update snapshots.",
"views.test.pw.extension.settingsView": "Playwright"
}
2 changes: 2 additions & 0 deletions package.nls.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"contributes.command.pw.extension.toggle.reuseBrowser": "是否复用 Playwright 浏览器",
"contributes.command.pw.extension.toggle.showTrace": "是否显示 Playwright 浏览器的跟踪",
"contributes.command.pw.extension.toggle.runGlobalSetupOnEachRun": "切换 Playwright 全局设置的重用",
"contributes.command.pw.extension.toggle.updateSnapshots": "切换快照更新",
"configuration.playwright.env": "Playwright Test 运行环境变量",
"configuration.playwright.reuseBrowser": "在测试用例间显示并复用 Playwright 浏览器",
"configuration.playwright.showTrace": "显示 Playwright 浏览器的跟踪",
"configuration.playwright.updateSnapshots": "更新快照",
"configuration.playwright.runGlobalSetupOnEachRun": "不要重复使用全局设置",
"views.test.pw.extension.settingsView": "Playwright"
}
2 changes: 2 additions & 0 deletions src/playwrightTestCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export class PlaywrightTestCLI {
args.push(`--workers=${options.workers}`);
if (options.trace)
args.push(`--trace=${options.trace}`);
if (options.updateSnapshots === 'all')
args.push(`--update-snapshots`);
await this._innerSpawn(locations, args, options, reporter, token);
}

Expand Down
1 change: 1 addition & 0 deletions src/playwrightTestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type PlaywrightTestRunOptions = {
video?: 'on' | 'off';
reuseContext?: boolean;
connectWsEndpoint?: string;
updateSnapshots?: 'all' | 'none' | 'missing';
};

export interface RunHooks {
Expand Down
2 changes: 2 additions & 0 deletions src/settingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class SettingsModel extends DisposableBase {
showBrowser: Setting<boolean>;
showTrace: Setting<boolean>;
runGlobalSetupOnEachRun: Setting<boolean>;
updateSnapshots: Setting<boolean>;

constructor(vscode: vscodeTypes.VSCode, context: vscodeTypes.ExtensionContext) {
super();
Expand All @@ -55,6 +56,7 @@ export class SettingsModel extends DisposableBase {
this.showBrowser = this._createSetting('reuseBrowser');
this.showTrace = this._createSetting('showTrace');
this.runGlobalSetupOnEachRun = this._createSetting('runGlobalSetupOnEachRun');
this.updateSnapshots = this._createSetting('updateSnapshots');

this._disposables.push(
this._onChange,
Expand Down
15 changes: 9 additions & 6 deletions src/settingsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur
<title>Playwright</title>
</head>
<body>
<div id="actions" class="list"></div>
<div class="section-header">${vscode.l10n.t('PROJECTS')}</div>
<div class="list" id="model-selector">
<div>
<label title="${vscode.l10n.t('Select Playwright Config')}">
Expand All @@ -266,7 +268,6 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur
<span id="configToolbar"></span>
</div>
</div>
<div class="section-header">${vscode.l10n.t('PROJECTS')}</div>
<div data-testid="projects" id="projects" class="list"></div>
<div class="section-header">${vscode.l10n.t('SETTINGS')}</div>
<div class="list">
Expand All @@ -282,18 +283,20 @@ function htmlForWebview(vscode: vscodeTypes.VSCode, extensionUri: vscodeTypes.Ur
${vscode.l10n.t('Show trace viewer')}
</label>
</div>
</div>
<div class="section-header">${vscode.l10n.t('TOOLS')}</div>
<div id="actions" class="list"></div>
<div class="section-header">${vscode.l10n.t('SETUP')}</div>
<div class="list">
<div>
<label>
<input type="checkbox" setting="updateSnapshots"></input>
${vscode.l10n.t('Update snapshots')}
</label>
</div>
<div>
<label>
<input type="checkbox" setting="runGlobalSetupOnEachRun"></input>
${vscode.l10n.t('Run global setup on each run')}
</label>
</div>
</div>
<div class="section-header">${vscode.l10n.t('SETUP')}</div>
<div id="rareActions" class="list"></div>
</body>
<script nonce="${nonce}">
Expand Down
1 change: 1 addition & 0 deletions src/testModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export class TestModel extends DisposableBase {
video,
reuseContext: showBrowser,
connectWsEndpoint: showBrowser ? externalOptions.connectWsEndpoint : undefined,
updateSnapshots: this._embedder.settingsModel.updateSnapshots.get() ? 'all' : undefined,
};

try {
Expand Down
1 change: 1 addition & 0 deletions tests/mock/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,7 @@ export class VSCode {
'playwright.reuseBrowser': false,
'playwright.showTrace': false,
'playwright.runGlobalSetupOnEachRun': false,
'playwright.updateSnapshots': false,
'workbench.colorTheme': 'Dark Modern',
};
this.workspace.getConfiguration = (scope: string) => {
Expand Down