Skip to content

EndemolShineGroup/serverless-test-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner

MIT Licensed NPM Version Build Status Greenkeeper Status

Code Issues Codebase Maintainability Test Coverage Jest

Serverless Commitizen Semantic Release Prettier

This project exports the Serverless Framework's own testing utilities so you can use them to test your own projects.

Installation

yarn add -D @endemolshinegroup/serverless-test-utils

Usage

Example

import fs from 'fs';
import path from 'path';

import {
  createTestService,
  deployService,
  removeService,
} from '@endemolshinegroup/serverless-test-utils';

describe('MyServerlessProject', () => {
  let serviceName;

  beforeAll(() => {
    serviceName = createTestService('aws-nodejs', process.cwd());
    deployService();
  });

  it('should have create cloudformation files and functions zip', () => {
    const deployedFiles = fs.readdirSync(path.join(process.cwd(), '.serverless'));
    expect(deployedFiles[0]).toEqual('cloudformation-template-create-stack.json');
    expect(deployedFiles[1]).toEqual('cloudformation-template-update-stack.json');
    expect(deployedFiles[2]).toEqual('serverless-state.json');
    expect(deployedFiles[3]).toMatch(/test-[0-9]{1,}-[0-9]{1,}.zip/);
  });

  afterAll(() => {
    removeService();
  });
});