
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
serverless-jest-plugin
Advanced tools
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.
This plugins does the following:
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
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}
Tests can also be added to existing handlers using
sls create test -f functionName
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.
https://github.com/nordcloud/serverless-jest-plugin/blob/master/LICENSE
FAQs
Serverless plugin for test driven development using Jest
The npm package serverless-jest-plugin receives a total of 1,821 weekly downloads. As such, serverless-jest-plugin popularity was classified as popular.
We found that serverless-jest-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.