Skip to content
Merged
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
5 changes: 5 additions & 0 deletions packages/cli-repl/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ export async function eventually(fn: Function, options: { frequency?: number; ti
await new Promise(resolve => setTimeout(resolve, options.frequency));
}

Object.assign(err, {
timedOut: true,
timeout: options.timeout,
message: `[Timed out ${options.timeout}ms] ${err.message}`
});
throw err;
}
6 changes: 4 additions & 2 deletions packages/cli-repl/test/test-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { eventually } from './helpers';
export type TestShellStartupResult = { state: 'prompt' | 'exit'; exitCode?: number | undefined };
type SignalType = ChildProcess extends { kill: (signal: infer T) => any } ? T : never;

const PROMPT_PATTERN = /^([^>]*> ?)+$/m;
// Assume that prompt strings are those that end in '> ' but do not contain
// < or > (so that e.g. '- <repl>' in a stack trace is not considered a prompt).
const PROMPT_PATTERN = /^([^<>]*> ?)+$/m;
const ERROR_PATTERN_1 = /Thrown:\n([^>]*)/mg; // node <= 12.14
const ERROR_PATTERN_2 = /Uncaught[:\n ]+([^>]*)/mg;

Expand Down Expand Up @@ -133,7 +135,7 @@ export class TestShell {
throw new assert.AssertionError({
message: 'expected prompt',
expected: PROMPT_PATTERN.toString(),
actual: this._output
actual: this._output.slice(0, start) + '[prompt search starts here]' + output
});
}
});
Expand Down