Skip to content

Commit bb88c9e

Browse files
committed
Refactored "runAndGetOutputWithoutErrors" into "waitForCleanOutout"
1 parent 0f92ba5 commit bb88c9e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/e2e-tests/test/e2e-snapshot.spec.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
skipIfApiStrict,
33
startSharedTestServer,
44
} from '../../../testing/integration-testing-hooks';
5-
import { TestShell } from './test-shell';
65
import { expect } from 'chai';
76

87
const setDifference = <T>(a: T[], b: T[]) => a.filter((e) => !b.includes(e));
@@ -57,7 +56,7 @@ describe('e2e snapshot support', function () {
5756
] = (
5857
await Promise.all(
5958
argLists.map((args) =>
60-
TestShell.runAndGetOutputWithoutErrors({ args })
59+
this.startTestShell({ args }).waitForCleanOutput()
6160
)
6261
)
6362
).map((output) =>

packages/e2e-tests/test/test-shell.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class TestShell {
5050
/**
5151
* Starts a test shell.
5252
*
53-
* Beware that the caller is responsible for calling {@link TestShell.kill} (and potentially {@link TestShell.waitForExit}).
53+
* Beware that the caller is responsible for calling {@link kill} (and potentially {@link waitForExit}).
5454
*
5555
* Consider calling the `startTestShell` function on a {@link Mocha.Context} instead, as that manages the lifetime the shell
5656
* and ensures it gets killed eventually.
@@ -108,15 +108,6 @@ export class TestShell {
108108
return shell;
109109
}
110110

111-
static async runAndGetOutputWithoutErrors(
112-
options: TestShellOptions
113-
): Promise<string> {
114-
const shell = this.start(options);
115-
await shell.waitForExit();
116-
shell.assertNoErrors();
117-
return shell.output;
118-
}
119-
120111
debugInformation() {
121112
return {
122113
pid: this.process.pid,
@@ -232,6 +223,15 @@ export class TestShell {
232223
return this._onClose;
233224
}
234225

226+
/**
227+
* Waits for the shell to exit, asserts no errors and returns the output.
228+
*/
229+
async waitForCleanOutput(): Promise<string> {
230+
await this.waitForExit();
231+
this.assertNoErrors();
232+
return this.output;
233+
}
234+
235235
async waitForPromptOrExit(): Promise<TestShellStartupResult> {
236236
return Promise.race([
237237
this.waitForPrompt().then(() => ({ state: 'prompt' } as const)),

0 commit comments

Comments
 (0)