testlab package
A collection of test utilities we use to write LoopBack tests.
Remarks
Test utilities to help write LoopBack 4 tests:
expect- behavior-driven development (BDD) style assertions -sinon- test spies: functions recording arguments and other information for all of their calls - stubs: functions (spies) with pre-programmed behavior - mocks: fake methods (like spies) with pre-programmed behavior (like stubs) as well as pre-programmed expectations - Helpers for creatingsupertestclients for LoopBack applications - HTTP request/response stubs for writing tests without a listening HTTP server - Swagger/OpenAPI spec validation
Classes
| Class | Description |
|---|---|
|
TestSandbox class provides a convenient way to get a reference to a sandbox folder in which you can perform operations for testing purposes. |
Functions
| Function | Description |
|---|---|
|
Create a SuperTest client connected to an HTTP server listening on an ephemeral port and calling | |
|
Create a SuperTest client for a running RestApplication instance. It is the responsibility of the caller to ensure that the app is running and to stop the application after all tests are done. | |
|
Creates a new object with the given functions as the prototype and stubs all implemented functions. Note: The given constructor function is not invoked. See also the stub API. This is a helper method replacing | |
|
Creates a Logger that logs an Error if the HTTP status code is not expected | |
|
Create an HTTP-server configuration that works well in test environments. - Ask the operating system to assign a free (ephemeral) port. - Use IPv4 localhost | |
|
Async wrapper for making HTTP GET requests | |
|
Async wrapper for making HTTPS GET requests | |
|
Helper function for skipping tests when a certain condition is met. | |
|
Helper function for skipping tests on Travis CI. | |
|
JSON encoding does not preserve properties that are undefined As a result, deepEqual checks fail because the expected model value contains these undefined property values, while the actual result returned by REST API does not. Use this function to convert a model instance into a data object as returned by REST API | |
Interfaces
| Interface | Description |
|---|---|
|
An object that requires host and port properties | |
|
Options for a test sandbox |
Variables
| Variable | Description |
|---|---|
Type Aliases
| Type Alias | Description |
|---|---|
|
A function defining a new test case or a test suite, e.g. |