class ShellSession
A shell session created by ShellTester#session.
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ShellSession
class.
Methods
capture(name, extra)
Captures the current terminal state into a file. It also prints the terminal state to the console.
It will be written to tmp/output/${name}.js
and will begin with SESSION_DATA=
, followed by the JSON-encoded ShellSessionCapturedData.
Extra properties may be added to the session by passing the extra
argument.
Name | Type | Description |
---|---|---|
|
|
The name of the capture file. |
|
|
Extra properties to add to the captured session data. |
Returns |
|
capture(name: string, extra?: Record<string, any>): Promise<void>;
expect(str, timeoutMs)
Waits for the given string to be printed on the terminal. Gives up once timeoutMs
has elapsed.
Name | Type | Description |
---|---|---|
|
|
The text to wait for. |
|
|
The timeout in milliseconds. |
Returns |
|
expect(str: string, timeoutMs?: number): Promise<void>;
resize(cols, rows)
Resizes the terminal.
Name | Type | Description |
---|---|---|
|
|
The number of columns. |
|
|
The number of rows. |
Returns |
|
resize(cols?: number, rows?: number): Promise<void>;
retry(callback, timeoutMs)
Calls the given callback()
function repeatedly until it no longer throws an error. Gives up once timeoutMs
has elapsed.
Name | Type | Description |
---|---|---|
|
|
The function to call. |
|
|
The timeout in milliseconds. |
Returns |
|
retry<T>(callback: () => Promise<T>, timeoutMs?: number): Promise<T>;
send(data)
Send a string to the terminal.
Note that newline characters will *\*not\*\* be added automatically. To send a newline, use \r
.
You can also send control characters such as \x03
(^C).
Name | Type | Description |
---|---|---|
|
|
The string to send. |
Returns |
|
send(data: string): Promise<void>;