Allow tests to run multiple times

This commit is contained in:
Daniel Imms 2022-06-15 12:35:53 -07:00
parent 7548fed110
commit 18408b9090
No known key found for this signature in database
GPG key ID: E5CF412B63651C69

View file

@ -7,29 +7,32 @@ import { Application, Terminal, SettingsEditor, TerminalCommandIdWithValue, Term
import { setTerminalTestSettings } from './terminal-helpers'; import { setTerminalTestSettings } from './terminal-helpers';
export function setup() { export function setup() {
describe('Terminal Shell Integration', () => { for (let i = 0; i < 100; i++) {
let terminal: Terminal; describe(`Terminal Shell Integration ${i}`, () => {
let settingsEditor: SettingsEditor; let terminal: Terminal;
let app: Application; let settingsEditor: SettingsEditor;
// Acquire automation API let app: Application;
before(async function () { // Acquire automation API
app = this.app as Application; before(async function () {
terminal = app.workbench.terminal; app = this.app as Application;
settingsEditor = app.workbench.settingsEditor; terminal = app.workbench.terminal;
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.enabled', 'true'); settingsEditor = app.workbench.settingsEditor;
await setTerminalTestSettings(app); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.enabled', 'true');
}); await setTerminalTestSettings(app);
});
afterEach(async function () { after(async function () {
await app.workbench.terminal.runCommand(TerminalCommandId.KillAll); await settingsEditor.clearUserSettings();
await settingsEditor.clearUserSettings(); });
});
async function createShellIntegrationProfile() { afterEach(async function () {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, process.platform === 'win32' ? 'PowerShell' : 'bash'); await app.workbench.terminal.runCommand(TerminalCommandId.KillAll);
} });
async function createShellIntegrationProfile() {
await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile, process.platform === 'win32' ? 'PowerShell' : 'bash');
}
for (let i = 0; i < 100; i++) {
describe(`Shell integration ${i}`, function () { describe(`Shell integration ${i}`, function () {
describe('Decorations', function () { describe('Decorations', function () {
describe('Should show default icons', function () { describe('Should show default icons', function () {
@ -39,7 +42,7 @@ export function setup() {
}); });
it('Success', async () => { it('Success', async () => {
await createShellIntegrationProfile(); await createShellIntegrationProfile();
await terminal.runCommandInTerminal(`ls`); await terminal.runCommandInTerminal(`echo "success"`);
await terminal.assertCommandDecorations({ placeholder: 1, success: 1, error: 0 }); await terminal.assertCommandDecorations({ placeholder: 1, success: 1, error: 0 });
}); });
it('Error', async () => { it('Error', async () => {
@ -52,7 +55,7 @@ export function setup() {
it('Should update and show custom icons', async () => { it('Should update and show custom icons', async () => {
await createShellIntegrationProfile(); await createShellIntegrationProfile();
await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 }); await terminal.assertCommandDecorations({ placeholder: 1, success: 0, error: 0 });
await terminal.runCommandInTerminal(`ls`); await terminal.runCommandInTerminal(`echo "success"`);
await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`); await terminal.runCommandInTerminal(`fsdkfsjdlfksjdkf`);
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIcon', '"zap"'); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIcon', '"zap"');
await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconSuccess', '"zap"'); await settingsEditor.addUserSetting('terminal.integrated.shellIntegration.decorationIconSuccess', '"zap"');
@ -62,6 +65,6 @@ export function setup() {
}); });
}); });
}); });
} });
}); }
} }