---
lang: en
title: 'API docs: testlab'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.testlab.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/testlab](./testlab.md)

## testlab package

[@loopback/testlab](https://github.com/strongloop/loopback-next/tree/master/packages/testlab)

## Classes

|  Class | Description |
|  --- | --- |
|  [TestSandbox](./testlab.testsandbox.md) | 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 |
|  --- | --- |
|  [createClientForHandler(handler)](./testlab.createclientforhandler.md) | Create a SuperTest client connected to an HTTP server listening on an ephemeral port and calling <code>handler</code> to handle incoming requests. |
|  [createRestAppClient(app)](./testlab.createrestappclient.md) | 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. |
|  [createStubInstance(constructor)](./testlab.createstubinstance.md) | 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 <code>sinon.createStubInstance</code> and working around the limitations of TypeScript and Sinon, where Sinon is not able to list private/protected members in the type definition of the stub instance and therefore the stub instance cannot be assigned to places expecting TType. See also - https://github.com/Microsoft/TypeScript/issues/13543 - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811 |
|  [createUnexpectedHttpErrorLogger(expectedStatusCode)](./testlab.createunexpectedhttperrorlogger.md) | Creates a Logger that logs an Error if the HTTP status code is not expected |
|  [givenHttpServerConfig(customConfig)](./testlab.givenhttpserverconfig.md) | Create an HTTP-server configuration that works well in test environments. - Ask the operating system to assign a free (ephemeral) port. - Use IPv4 localhost <code>127.0.0.1</code> to avoid known IPv6 issues in Docker-based environments like Travis-CI. - Provide default TLS key &amp; cert when <code>protocol</code> is set to <code>https</code>. |
|  [httpGetAsync(urlString)](./testlab.httpgetasync.md) | Async wrapper for making HTTP GET requests |
|  [httpsGetAsync(urlString)](./testlab.httpsgetasync.md) | Async wrapper for making HTTPS GET requests |
|  [itSkippedOnTravis(expectation, callback)](./testlab.itskippedontravis.md) | Helper function for skipping tests on Travis env - legacy variant supporting <code>it</code> only. |
|  [skipIf(skip, verb, name, args)](./testlab.skipif.md) | Helper function for skipping tests when a certain condition is met. |
|  [skipOnTravis(verb, name, args)](./testlab.skipontravis.md) | Helper function for skipping tests on Travis CI. |
|  [stubExpressContext(requestOptions)](./testlab.stubexpresscontext.md) |  |
|  [stubHandlerContext(requestOptions)](./testlab.stubhandlercontext.md) |  |
|  [stubServerRequest(options)](./testlab.stubserverrequest.md) |  |
|  [stubServerResponse(request, onEnd)](./testlab.stubserverresponse.md) |  |
|  [toJSON(value)](./testlab.tojson.md) |  |
|  [toJSON(value)](./testlab.tojson_9.md) |  |
|  [toJSON(value)](./testlab.tojson_10.md) |  |
|  [toJSON(value)](./testlab.tojson_11.md) |  |
|  [toJSON(value)](./testlab.tojson_12.md) |  |
|  [toJSON(value)](./testlab.tojson_13.md) |  |
|  [toJSON(value)](./testlab.tojson_14.md) |  |
|  [toJSON(value)](./testlab.tojson_1.md) |  |
|  [toJSON(value)](./testlab.tojson_2.md) |  |
|  [toJSON(value)](./testlab.tojson_3.md) | 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 |
|  [toJSON(value)](./testlab.tojson_4.md) |  |
|  [toJSON(value)](./testlab.tojson_5.md) |  |
|  [toJSON(value)](./testlab.tojson_6.md) |  |
|  [toJSON(value)](./testlab.tojson_7.md) |  |
|  [toJSON(value)](./testlab.tojson_8.md) |  |
|  [validateApiSpec(spec)](./testlab.validateapispec.md) |  |

## Interfaces

|  Interface | Description |
|  --- | --- |
|  [ExpressContextStub](./testlab.expresscontextstub.md) |  |
|  [HandlerContextStub](./testlab.handlercontextstub.md) |  |
|  [RestApplicationLike](./testlab.restapplicationlike.md) |  |
|  [RestServerLike](./testlab.restserverlike.md) |  |
|  [TestContext](./testlab.testcontext.md) |  |
|  [TestFn](./testlab.testfn.md) | \* LEGACY API FOR BACKWARDS COMPATIBILITY \*\* |

## Variables

|  Variable | Description |
|  --- | --- |
|  [expect](./testlab.expect.md) |  |
|  [inject](./testlab.inject.md) |  |

## Type Aliases

|  Type Alias | Description |
|  --- | --- |
|  [Client](./testlab.client.md) |  |
|  [ConfigRetval](./testlab.configretval.md) |  |
|  [ObservedResponse](./testlab.observedresponse.md) |  |
|  [ShotCallback](./testlab.shotcallback.md) |  |
|  [ShotResponseCtor](./testlab.shotresponsector.md) |  |
|  [StubbedInstanceWithSinonAccessor](./testlab.stubbedinstancewithsinonaccessor.md) |  |
|  [TestDefinition](./testlab.testdefinition.md) | A function defining a new test case or a test suite, e.g. <code>it</code> or <code>describe</code>. |


