Last active
June 30, 2021 20:13
-
-
Save hoangsetup/c9080df5b83d746c307b1445bc303a71 to your computer and use it in GitHub Desktop.
Revisions
-
hoangsetup revised this gist
Apr 25, 2021 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,10 @@ describe('hello', () => { main = (await import('./handler')).main; }); afterEach(() => { jest.resetModules(); }); it('should return hello object', async () => { const event = { body: { -
hoangsetup created this gist
Apr 25, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import { mocked } from 'ts-jest/utils'; import { Handler } from 'aws-lambda'; import { middyfy } from '@libs/lambda'; jest.mock('@libs/lambda'); describe('hello', () => { let main; let mockedMiddyfy: jest.MockedFunction<typeof middyfy>; beforeEach(async () => { mockedMiddyfy = mocked(middyfy); mockedMiddyfy.mockImplementation((handler: Handler) => { return handler as never; }); main = (await import('./handler')).main; }); it('should return hello object', async () => { const event = { body: { name: 'test-name' } } as any; const actual = await main(event); expect(actual).toEqual({ message: `Hello ${event.body.name}, welcome to the exciting Serverless world!`, event, }); }); });