Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@loopback/testlab

Package Overview
Dependencies
Maintainers
22
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loopback/testlab

A collection of test utilities we use to write LoopBack tests.

Source
npmnpm
Version
4.0.0-alpha.9
Version published
Weekly downloads
29K
-1.4%
Maintainers
22
Weekly downloads
 
Created
Source

LoopBack Test Lab

A collection of test utilities we use to write LoopBack tests.

Overview

Test utilities to help writing loopback-next 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 creating supertest clients for LoopBack applications
  • HTTP request/response stubs for writing tests without a listening HTTP server
  • Swagger/OpenAPI spec validation

Installation

$ npm install --save-dev @loopback/testlab

This package is typically used in tests, save it to devDependencies via --save-dev.

Basic use

import { expect } from '@loopback/testlab';

expect({key:'value'}).to.deepEqual({key: 'value'});
expect.exists(1);

API documentation

expect

Should.js configured in "as-function" mode (global Object.prototype is left intact) with an extra chaining word to.

sinon

Spies, mocks and stubs. Learn more at http://sinonjs.org/.

shot

Shot API Reference

validateApiSpec

Verify that your application API specification is a valid OpenAPI spec document.

import {validateApiSpec} from '@loopback/testlab';

describe('MyApp', () => {)
  it('has valid spec', async () => {
    const app = new MyApp();
    await validateApiSpec(app.getApiSpec());
  })
});

For more info about supertest, please refer to supertest

Contributions

Tests

run 'npm test' from the root folder.

Contributors

See all contributors.

License

MIT

FAQs

Package last updated on 29 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts