How to use the lambda-local.getLogger function in lambda-local

To help you get started, we’ve selected a few lambda-local examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taimos / serverless-todo-demo / backend / tst / todoDAO.spec.ts View on Github external
import * as AWS from 'aws-sdk-mock';
import { DocumentClient } from 'aws-sdk/lib/dynamodb/document_client';
import { expect } from 'chai';
import * as lambdaLocal from 'lambda-local';
import ScanOutput = DocumentClient.ScanOutput;
import PutItemInput = DocumentClient.PutItemInput;
import ScanInput = DocumentClient.ScanInput;
import { env } from 'process';
import { listTodos, save, ToDo } from '../lib/data';

lambdaLocal.getLogger().level = 'error';
env.TABLE_NAME = 'SomeTable';

describe('Test ToDo DAO - save', () => {

    it('should save todo', async () => {

        AWS.mock('DynamoDB.DocumentClient', 'put', (params : PutItemInput, callback) => {
            expect(params).to.haveOwnProperty('Item');
            expect(params.Item).to.have.property('id', 'todoId');
            expect(params.Item).to.have.property('text', 'ToDoText');
            expect(params.Item).to.have.property('state', 'OPEN');
            expect(params).to.have.property('TableName', 'SomeTable');
            callback(null, {});
        });

        const todo : ToDo = await save({
github taimos / serverless-todo-demo / backend / tst / todoApi.spec.ts View on Github external
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda';
import { expect } from 'chai';
import * as lambdaLocal from 'lambda-local';
import { describe, it } from 'mocha';
import * as proxyquire from 'proxyquire';
import { ToDo } from '../lib/data';

lambdaLocal.getLogger().level = 'error';

const todoStub = {
    listTodos: undefined,
    save: undefined,
};
const uuidStub = {
    v4: undefined,
};

const api = proxyquire('../lib/index', { './data': todoStub, 'node-uuid': uuidStub });

describe('GetAPI', () => {
    beforeEach(() => {
        delete todoStub.listTodos;
    });

lambda-local

Commandline tool and API to run Lambda functions on your local machine.

MIT
Latest version published 7 months ago

Package Health Score

72 / 100
Full package analysis