File tree 3 files changed +23
-8
lines changed
3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change 44
44
"@aws-cdk/core" : " ^1.70.0" ,
45
45
"@commitlint/cli" : " ^11.0.0" ,
46
46
"@commitlint/config-conventional" : " ^11.0.0" ,
47
- "@types/fs-extra" : " ^9.0.1" ,
48
47
"@types/jest" : " ^26.0.14" ,
48
+ "@types/mock-fs" : " ^4.13.0" ,
49
49
"@types/node" : " ^12.12.38" ,
50
- "@types/ramda" : " ^0.27.30" ,
51
50
"@typescript-eslint/eslint-plugin" : " ^4.5.0" ,
52
51
"@typescript-eslint/parser" : " ^4.5.0" ,
53
52
"eslint" : " ^7.12.0" ,
54
53
"husky" : " ^4.3.0" ,
55
54
"jest" : " ^26.6.1" ,
56
- "mock-fs" : " ^4.12 .0" ,
55
+ "mock-fs" : " ^4.13 .0" ,
57
56
"semantic-release" : " ^17.2.1" ,
58
57
"ts-jest" : " ^26.4.0" ,
59
58
"typescript" : " ^4.0.3"
60
59
},
61
60
"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"
66
62
},
67
63
"peerDependencies" : {
68
64
"@aws-cdk/aws-lambda" : " ^1.0.0" ,
Original file line number Diff line number Diff line change 1
- import * as fs from 'fs-extra ' ;
1
+ import * as fs from 'fs' ;
2
2
import * as path from 'path' ;
3
3
4
4
export function extractFileName ( cwd : string , handler : string ) : string {
Original file line number Diff line number Diff line change
1
+ jest . mock ( 'esbuild' ) ;
2
+
1
3
import '@aws-cdk/assert/jest' ;
4
+
2
5
import { Stack } from '@aws-cdk/core' ;
6
+ import { buildSync } from 'esbuild' ;
7
+ import mockfs from 'mock-fs' ;
8
+
3
9
import { NodejsFunction } from '../src' ;
4
10
5
11
describe ( 'NodejsFunction tests' , ( ) => {
12
+ beforeAll ( ( ) => {
13
+ mockfs ( {
14
+ 'index.ts' : '' ,
15
+ 'package-lock.json' : '' ,
16
+ '.build' : { }
17
+ } ) ;
18
+ } ) ;
19
+
6
20
it ( 'Should not class constructor be thrown' , async ( ) => {
7
21
const stack = new Stack ( ) ;
8
22
const factory = ( ) => new NodejsFunction ( stack , 'lambda-function' , { } ) ;
9
23
expect ( factory ) . not . toThrow ( ) ;
24
+ expect ( buildSync ) . toBeCalledTimes ( 1 ) ;
10
25
expect ( stack ) . toHaveResource ( 'AWS::Lambda::Function' , {
11
26
Handler : 'index.handler' ,
12
27
} ) ;
13
28
} ) ;
29
+
30
+ afterAll ( ( ) => {
31
+ mockfs . restore ( ) ;
32
+ } ) ;
14
33
} ) ;
You can’t perform that action at this time.
0 commit comments