Socket
Book a DemoInstallSign in
Socket

slspress-test

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slspress-test

A library for rapidly developing Serverless applications inspired by express

2.0.1
latest
Source
npmnpm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

slspress test

A collection of useful testing utilities to aid in the testing of serverless projects.

ServerlessOfflineManager

Use this to start and stop Serverless Offline instances from your tests. This allows you to run integration tests against a local version of your code using Serverless Offline. Both your serverless code and tests will run in the same node process making debugging a bit easier and as you write plain mocha tests IDEs with Mocha support integrate well.

Usage

Example using ServerlessOfflineManager with chai and request to test an endpoint. The global before and after functions will start and stop a serverless application in the current working directory prior to and after running all of your tests.

const OfflineManager = require('slspress-test').ServerlessOfflineManager;
const expect = require('chai').expect;
const request = require('request-promise-native');

describe('Integration Test', function() {
  this.timeout(1000 * 10);

  const offlineManager = new OfflineManager();

  let testUrl = null;
  before(() => offlineManager.start(environment).then(url => testUrl = url));
  after(() => offlineManager.stop());

  it('tests something', function () {
    return request(`${testUrl}/some/url`)
      .then(body => expect(body).to.equal('Something'));
  });
});

Passing properties

You can pass properties to serverless offline by adding a constructor argument. For example if the application you wish to test is not in the working directory you could do something like this new OfflineManager({ serverless: { servicePath: __dirname + '/your-app' }}).

Keywords

serverless

FAQs

Package last updated on 09 Aug 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.