Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
148c5c2
fix mocha run on test event
laardee Oct 17, 2017
3fbcfb0
Nordcloud rebrand
mpuittinen Dec 21, 2017
5b20994
Merge branch 'master' of https://github.com/SC5/serverless-mocha-plugin
mpuittinen Dec 21, 2017
d9f4795
Fix Travis url
mpuittinen Jan 1, 2018
5ef1408
Increase test timeout
mpuittinen Jan 1, 2018
91be34b
Replace deprecated babel-preset-es2015 with babel-preset-env
mpuittinen Jan 1, 2018
840c155
Add code coverage tests
mpuittinen Jan 1, 2018
bd41daf
Removed reference to serverless 1.x not being out
pcowgill Feb 1, 2018
66bcd21
Merge pull request #80 from pcowgill/patch-1
mpuittinen Feb 2, 2018
2e89df4
Add nyc_output to gitignore
mpuittinen Apr 3, 2018
c733666
Add support for Node 8.10 runtime
mpuittinen Apr 3, 2018
ae5b2fe
Release 1.8.0
mpuittinen Apr 3, 2018
0497d56
Remove tests for Node 4 (deprecated by AWS)
mpuittinen May 7, 2018
693a09d
Upgrade to lambda-wrapper 0.3 (async support)
mpuittinen May 7, 2018
dfba24f
Merge branch 'master' into fix-mocha-run-on-test
mpuittinen May 7, 2018
acf224a
Merge branch 'fix-mocha-run-on-test'
mpuittinen May 7, 2018
a800d48
docs: working mode to start localhost serverless
marcoonroad May 8, 2018
c2bcbd5
Merge pull request #84 from marcoonroad/patch-1
mpuittinen May 8, 2018
1cd6467
Release 1.8.1
mpuittinen May 15, 2018
527dfb5
Merge branch 'master' of https://github.com/nordcloud/serverless-moch…
mpuittinen May 15, 2018
7b09d3a
Rebuild package-lock.json
mpuittinen May 15, 2018
e283cfe
Update mocha due to vulnerabilities
mpuittinen May 15, 2018
eb8cd3f
Update mocha due to vulnerabilities
mpuittinen May 15, 2018
2de481b
Add missing delayed-stream module
mpuittinen May 16, 2018
88c3c6f
Release 1.8.3
mpuittinen May 16, 2018
1a14cdb
Add flag to exit process when mocha finishes
c0d3d Sep 11, 2018
7101e8a
Merge pull request #91 from c0d3d/add-exit-flag
mpuittinen Sep 16, 2018
128bd02
Update version to 1.9.0
mpuittinen Sep 16, 2018
b773bef
Fix create function / test
mpuittinen Dec 15, 2018
d8f42fa
Fix sls invoke test with serverless 1.33
mpuittinen Dec 15, 2018
7c9c159
Fix creation with template path
mpuittinen Dec 15, 2018
6908f81
Fix creation with template path
mpuittinen Dec 15, 2018
142596f
Fix lint
mpuittinen Dec 16, 2018
80c3e7d
Fix tests being run multiple times
mpuittinen Jan 7, 2019
af9f5d1
Added timeout as a command line parameter.
christopherchubb Jan 16, 2019
9d039fd
fix process exit code on test fail
Feb 3, 2019
97e4d47
Mocha babel compiler options
Feb 3, 2019
7ba9626
Merge pull request #107 from Enase/exit-code
mpuittinen Feb 4, 2019
fec6063
Use failures for exit code
c0d3d Dec 3, 2018
1597aa1
Merge branch 'fix-exit-flag' of https://github.com/c0d3d/serverless-m…
mpuittinen Apr 2, 2019
8b0d67e
Merge branch 'c0d3d-fix-exit-flag'
mpuittinen Apr 2, 2019
ce1672f
Merge branch 'babel-options' of https://github.com/Enase/serverless-m…
mpuittinen Apr 2, 2019
17f4270
Merge branch 'Enase-babel-options'
mpuittinen Apr 2, 2019
548b9f7
Merge branch 'fix-timeout' of https://github.com/christopherchubb/ser…
mpuittinen Apr 2, 2019
65ed932
Add doc for timeout
mpuittinen Apr 2, 2019
f32413b
Bump version to 1.10
mpuittinen Apr 2, 2019
7823076
Merge branch 'christopherchubb-fix-timeout'
mpuittinen Apr 2, 2019
96edd5d
Node v10 support added
Jul 11, 2019
190ba26
Drop Node v6 support
Jul 11, 2019
bba0fb4
Travis matrix added
Jul 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ node_modules
# IDE
.idea

# NYC
.nyc_output

# Mac
.DS_Store

Expand Down
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
language: node_js
node_js:
- '4.3.2'
- '6.10.0'
matrix:
include:
- name: "Node v8"
os: linux
node_js: '8'
env: TEST_SIUTE=8.10
- name: "Node v10"
os: linux
node_js: '10'
env: TEST_SIUTE=10.x
script:
- npm run lint
- npm test
- npx nyc mocha -t 30000 ./test/*$TEST_SIUTE*.js
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Serverless Mocha Plugin

[![Build Status](https://travis-ci.org/SC5/serverless-mocha-plugin.svg?branch=master)](https://travis-ci.org/SC5/serverless-mocha-plugin)
[![Build Status](https://travis-ci.org/nordcloud/serverless-mocha-plugin.svg?branch=master)](https://travis-ci.org/nordcloud/serverless-mocha-plugin)

A Serverless Plugin for the [Serverless Framework](http://www.serverless.com) which
adds support for test driven development using [mocha](https://mochajs.org/)
Expand Down Expand Up @@ -80,14 +80,14 @@ If you want to run the tests against the real Lambda functions, you can pass the
wrapper.init(liveFunction);
```

NOTE: Live running does not currently work. Waiting for serverless 1.0 to finalize / have required env variables available
NOTE: Live running does not currently work. Need to finalize / have required env variables available

### Running tests

Tests can be run directly using the "invoke test" command. This also initializes the environment variables based on your serverless.yml file and the SERVERLESS_TEST_ROOT variable that defines the root for the code to be tested.

```
sls invoke test [--stage stage] [--region region] [-f function1] [-f function2] [...]
sls invoke test [--stage stage] [--region region] [-t timeout] [-f function1] [-f function2] [...]
```

To use a mocha reporter (e.g. json), use the -R switch. Reporter options can be passed with the -O switch.
Expand Down Expand Up @@ -165,7 +165,7 @@ if [ -f .offline.pid ]; then
exit 1
fi

serverless offline start 2>1 > $TMPFILE &
serverless offline 2>1 > $TMPFILE &
PID=$!
echo $PID > .offline.pid

Expand All @@ -180,8 +180,27 @@ Sample stopOffline.sh
kill `cat .offline.pid`
rm .offline.pid
```

### Usage with [babel register](https://babeljs.io/docs/en/babel-register)

If you use mocha with [babel compiler](https://github.com/mochajs/mocha/wiki/compilers-deprecation) e.g. `sls invoke test --compilers js:@babel/register` \
Babel configuration can be determined with the custom `babelOptions` configuration in serverless.yml

```
custom:
serverless-mocha-plugin:
babelOptions:
presets: [["@babel/env", { "targets": { "node": "8.10" }, "shippedProposals": true, "useBuiltIns": "usage" }]]
plugins:
- ["@babel/plugin-transform-runtime"]
```
## Release History (1.x)

* 2019/04/02 - v1.10.0 - add timeout parameter
add babel options
* 2018/12/15 - v1.9.1 - fix to work with serverless 1.33 and later
* 2018/09/16 - v1.9.0 - add support for --exit option
* 2018/04/03 - v1.8.0 - add support for Node 8
* 2017/09/10 - v1.7.0 - ability to run scripts before / after tests
* 2017/09/09 - v1.6.0 - also run tests from subfolders of test
* 2017/07/11 - v1.4.1 - Add option --root for running tests on e.g. webpack build results residing in other directories,
Expand All @@ -199,5 +218,5 @@ rm .offline.pid

## License

Copyright (c) 2017 [SC5](http://sc5.io/), licensed for users and contributors under MIT license.
https://github.com/SC5/serverless-mocha-plugin/blob/master/LICENSE
Copyright (c) 2017 [Nordcloud](https://nordcloud.com/), licensed for users and contributors under MIT license.
https://github.com/nordcloud/serverless-mocha-plugin/blob/master/LICENSE
Loading