New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

lambda-mocha-runner

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-mocha-runner

Run mocha driven integration tests inside of an AWS Lambda.

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
16
433.33%
Maintainers
1
Weekly downloads
 
Created
Source

#Mocha Lambda Runner Easily run mocha tests programmatically from a lambda. This makes running integration tests from an AWS Lambda very simple.

Install

npm install lambda-mocha-runner

Contract

Runner.run takes two parameters:

  • mochaOptions - This gets passed directly into Mocha. For More Information.
  • testDir - The path to the directory with your tests. This should be relative to the root directory of your lambda.

Example

const Runner = require("lambda-mocha-runner");

class Lambda {
  static run(event, context, callback) {
    const context = { mochaOptions: {}, testDir: "path/to/test/files" };
    
    Runner.run(context)
      .then((response) => callback(null, response))
      .catch((err) => callback(err));
  }
}

module.exports = Lambda;

Sample Response Object

All Tests Passing

{
  suite: { type: "suite", isPassing: true, numPassing: 2, numFailing: 0 },
  tests: [
    {
      type: "test",
      isPassing: true,
      durationInMillis: 100,
      testTitle: "Given When Then it should do 1",
      stackTrace: ""
    },
    {
      type: "test",
      isPassing: true,
      durationInMillis: context.duration,
      testTitle: "Given When Then it should do 2",
      stackTrace: ""
    }
  ]
};

One Test Failing

{
  suite: { type: "suite", isPassing: false, numPassing: 1, numFailing: 1 },
  tests: [
    {
      type: "test",
      isPassing: true,
      durationInMillis: 100,
      testTitle: "Given When Then it should do 1",
      stackTrace: ""
    },
    {
      type: "test",
      isPassing: false,
      durationInMillis: context.duration,
      testTitle: "Given When Then it should do 2",
      stackTrace: "Some Strack Trace Will Be Here"
    }
  ]
};

Keywords

StriveNine

FAQs

Package last updated on 24 Apr 2020

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