Globals
In the new test environment, several utilities are available directly or via the module scope of the test worker.
chai
The chai library is used for assertions. The following are available:
assert: Theassertmodule: https://www.chaijs.com/api/assert/expect: Theexpectmodule: https://www.chaijs.com/api/bdd/AssertionError: TheAssertionErrorclass.
ROOT
The root of the workspace. This is available as a global variable.
path utilities
The node:path and node:fs/promises modules are available as:
join: Fromnode:path.readFile: Fromnode:fs/promises.writeFile: Fromnode:fs/promises.
Built-in Helpers
The following helpers are available directly in the test context:
controlWrapper: Retries a function until it succeeds.getBashHistory: Gets the.logs/.bash_history.logcontents.getCommandOutput: Returns the output of a command.getCWD: Gets the.logs/.cwd.logcontents.getLastCommand: Gets the \(n^{th}\) latest line from the bash history.getLastCWD: Gets the \(n^{th}\) latest line from the CWD history.getTemp: Gets the.logs/.temp.logcontents.getTerminalOutput: Gets the.logs/.terminal_out.logcontents.importSansCache: Imports a module while bypassing the Node.js cache.
Collisions
As the tests are run in the context of the test worker, variable naming collisions may occur. To avoid this, it is recommended to prefix object names with __ (dunder).