• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin for Serverless Framework which adds support for test-driven development using Jest

Serverless Jest Plugin

Build Status

A Serverless Plugin for the Serverless Framework which adds support for test-driven development using jest

THIS PLUGIN REQUIRES SERVERLESS V1.0 OR LATER!

More familiar with Mocha? Try serverless-mocha-plugin.

Introduction

This plugins does the following:

  • It provides commands to create and run tests manually
  • It provides a command to create a function, which automatically also creates a test

Installation

In your service root, run:

npm install --save-dev serverless-jest-plugin

Add the plugin to serverless.yml:

plugins:
  - serverless-jest-plugin
custom:
  jest:
    # You can pass jest options here
    # See details here: https://facebook.github.io/jest/docs/configuration.html
    # For instance, uncomment next line to enable code coverage
    # collectCoverage: true

Usage

Creating functions

Functions (and associated tests) can be created using the command

sls create function -f functionName --handler handler

e.g.

sls create function -f myFunction --handler functions/myFunction/index.handler

creates a new function myFunction into serverless.yml with a code template for the handler in functions/myFunction/index.js and a Javascript function module.exports.handler as the entrypoint for the Lambda function. A test template is also created into test/myFunction.js. Optionally tests can be created to specific folder using --path or -p switch, e.g.

sls create function -f myFunction --handler functions/myFunction/index.handler --path tests

To create tests next to handler use --path {function}, in following example test file myFunction.test.js is created to functions/myFunction/ directory.

sls create function -f myFunction --handler functions/myFunction/index.handler --path {function}

Creating tests

Tests can also be added to existing handlers using

sls create test -f functionName

Running tests

Tests can be run directly using Jest or using the "invoke test" command

sls invoke test [--stage stage] [--region region] [-f function]

If no function names are passed to "invoke test", all tests related to handler functions are run.

License

https://github.com/nordcloud/serverless-jest-plugin/blob/master/LICENSE

More Repositories

1

serverless-mocha-plugin

Plugin for Serverless Framework which adds support for test-driven development using Mocha
JavaScript
160
star
2

serverless-kms-secrets

🔑🔐☁️ Serverless plugin to encrypt variables with KMS (DEPRECATED)
JavaScript
113
star
3

serverless-plugin-additional-stacks

Additional Stacks Plugin for Serverless 1.x
JavaScript
101
star
4

cognitocurl

🦉🤖Easily sign curl calls to API Gateway with Cognito authorization token.
TypeScript
90
star
5

serverless-boilerplate

Serverless project template
JavaScript
82
star
6

pat-frontend-template

React frontend template based on Vite for Nordcloud's Platform & Tools
TypeScript
58
star
7

assume-role-arn

🤖🎩assume-role-arn allows you to easily assume an AWS IAM role in your CI/CD pipelines, without worrying about external dependencies.
Go
55
star
8

azure-pipelines-templates

Templates to be reused in our Azure Pipelines projects
31
star
9

lambda-wrapper

Wrapper for running lambda modules locally during development
JavaScript
30
star
10

GNUI

💅 Nordcloud's design system for SaaS products.
TypeScript
30
star
11

cognito-authorizer

Build your AWS API Gateway custom authorizer lambda without the need to handle tokens by yourself. Just implement the logic...
Go
24
star
12

aws-assume-role

GitHub action to assume subsequent AWS roles
Shell
23
star
13

aws-codepipeline-cfn-provider

☁️✨⚙️AWS Codepipeline Lambda to deploy stuff using AWS CloudFormation.
Python
23
star
14

azure-tag-manager

Azure Tag Manager, enforce tags at scale.
Go
21
star
15

codepipeline-datadog-events

Tool for monitoring AWS CodePipeline status and pushing events to Datadog, Slack and Cloudwatch.
TypeScript
20
star
16

cognito-go-auth

Simple library to sign requests using cognito Google federated authentication.
Go
17
star
17

cfn-encrypt

🔑🔐☁️ Cloudformation custom resource that enables creation of KMS encrypted strings and SSM secure parameters
Python
13
star
18

cfn-datadog

🐕⚙️Cloudformation custom resources that integrate with datadog
Python
10
star
19

mfacli

Go
9
star
20

azure-go-example

🖖Example app in go Azure SDK
Go
8
star
21

terraform-provider-imagefactory

ImageFactory terraform provider
Go
7
star
22

aws-rds-manager

☁️🛠✨ Provides utilities for the management of RDS snapshots
Python
6
star
23

ncerrors

An error wrapping library with an ability to add arbitrary fields to errors and record stack trace.
Go
4
star
24

mca-cli

CLI to help automating MCA work
TypeScript
4
star
25

mca-monitoring

Separate library for MCA monitoring generated with MCA CLI.
TypeScript
3
star
26

serverless.fi

serverless.fi website
HTML
2
star
27

klarity-scanner-vmware-cli

Klarity self-hosted scanner for your VMware environments
Go
2
star
28

klarity-apps-examples

Klarity apps examples, free to use
1
star
29

cloudtrail-activity-events

1
star
30

serverless-tdd-plugin

serverless-mocha-plugin reborn.
JavaScript
1
star
31

nordcloud-webassembly-lambda-demo

Nordcloud WebAssembly Lambda Demo
TypeScript
1
star
32

eslint-config-pat

Shareable ESLint config for PAT projects
JavaScript
1
star
33

log-forwarder

Golang based application to consume exported Cloud Logging entries via Pub/Sub subscription and log the entries on configured, central GCP Project.
Go
1
star
34

pytanko-bot

⁉️ Pytanko bot to post questions into a graphQL api (check https://github.com/nordcloud/pytanko-ui)
Go
1
star
35

lambdas-presentation-2018

JavaScript
1
star
36

aksworkshop

1
star
37

supermaestro-manifest-example

1
star
38

azure-cloud-foundation

1
star
39

kubernetes-fast-track-program

The Kubernetes Fast-Track program is an initiative to fast-track Nordcloud engineers onto Kubernetes. This Github project provides the necessary materials and tools to practice using Docker containers and Kubernetes.
Dockerfile
1
star