Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 58d319d

Browse files
test: fix test
1 parent 0427f7e commit 58d319d

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

‎package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,21 @@
4444
"@aws-cdk/core": "^1.70.0",
4545
"@commitlint/cli": "^11.0.0",
4646
"@commitlint/config-conventional": "^11.0.0",
47-
"@types/fs-extra": "^9.0.1",
4847
"@types/jest": "^26.0.14",
48+
"@types/mock-fs": "^4.13.0",
4949
"@types/node": "^12.12.38",
50-
"@types/ramda": "^0.27.30",
5150
"@typescript-eslint/eslint-plugin": "^4.5.0",
5251
"@typescript-eslint/parser": "^4.5.0",
5352
"eslint": "^7.12.0",
5453
"husky": "^4.3.0",
5554
"jest": "^26.6.1",
56-
"mock-fs": "^4.12.0",
55+
"mock-fs": "^4.13.0",
5756
"semantic-release": "^17.2.1",
5857
"ts-jest": "^26.4.0",
5958
"typescript": "^4.0.3"
6059
},
6160
"dependencies": {
62-
"esbuild": ">=0.6",
63-
"fs-extra": "^9.0.1",
64-
"globby": "^11.0.1",
65-
"ramda": "^0.27.0"
61+
"esbuild": ">=0.6"
6662
},
6763
"peerDependencies": {
6864
"@aws-cdk/aws-lambda": "^1.0.0",

‎src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'fs-extra';
1+
import * as fs from 'fs';
22
import * as path from 'path';
33

44
export function extractFileName(cwd: string, handler: string): string {

‎tests/index.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
1+
jest.mock('esbuild');
2+
13
import '@aws-cdk/assert/jest';
4+
25
import { Stack } from '@aws-cdk/core';
6+
import { buildSync } from 'esbuild';
7+
import mockfs from 'mock-fs';
8+
39
import { NodejsFunction } from '../src';
410

511
describe('NodejsFunction tests', () => {
12+
beforeAll(() => {
13+
mockfs({
14+
'index.ts': '',
15+
'package-lock.json': '',
16+
'.build': {}
17+
});
18+
});
19+
620
it('Should not class constructor be thrown', async () => {
721
const stack = new Stack();
822
const factory = () => new NodejsFunction(stack, 'lambda-function', {});
923
expect(factory).not.toThrow();
24+
expect(buildSync).toBeCalledTimes(1);
1025
expect(stack).toHaveResource('AWS::Lambda::Function', {
1126
Handler: 'index.handler',
1227
});
1328
});
29+
30+
afterAll(() => {
31+
mockfs.restore();
32+
});
1433
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /