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