Skip to content
Permalink
Browse files

Initial unit tests with Jest sample.

  • Loading branch information...
mwarman committed Mar 8, 2019
1 parent 9a98274 commit ee74344b594e2a76593b6078a4a956ea13b824aa
Showing with 3,715 additions and 0 deletions.
  1. +5 −0 test-jest/__tests__/index.test.js
  2. +15 −0 test-jest/index.js
  3. +19 −0 test-jest/package.json
  4. +14 −0 test-jest/serverless.yml
  5. +3,662 −0 test-jest/yarn.lock
@@ -0,0 +1,5 @@
const handler = require('../index');

test('should return greeting', () => {
expect(handler.getGreeting()).toBe('Hello World!');
});
@@ -0,0 +1,15 @@
const serverless = require('serverless-http');
const express = require('express');
const app = express();

_getGreeting = () => {
return 'Hello World!';
};

app.get('/', function(req,res) {
res.send(_getGreeting());
});

module.exports.handler = serverless(app);
// export functions for testing
module.exports.getGreeting = _getGreeting;
@@ -0,0 +1,19 @@
{
"name": "serverless-samples-test-jest",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/mwarman/serverless-samples",
"author": "Matt Warman",
"license": "Apache-2.0",
"private": false,
"scripts": {
"test": "jest"
},
"dependencies": {
"express": "^4.16.4",
"serverless-http": "^1.9.1"
},
"devDependencies": {
"jest": "^24.3.1"
}
}
@@ -0,0 +1,14 @@
service: samples-test-jest

provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1

functions:
app:
handler: index.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'

0 comments on commit ee74344

Please sign in to comment.
You can’t perform that action at this time.