1
- import '@aws-cdk/assert-internal/jest' ;
2
1
import * as fs from 'fs' ;
3
2
import * as path from 'path' ;
4
- import { ABSENT } from '@aws-cdk/assert-internal ' ;
3
+ import { Template , Match } from '@aws-cdk/assertions ' ;
5
4
import { Vpc } from '@aws-cdk/aws-ec2' ;
6
5
import { CodeConfig , Runtime } from '@aws-cdk/aws-lambda' ;
7
6
import { Stack } from '@aws-cdk/core' ;
@@ -40,7 +39,7 @@ test('NodejsFunction with .ts handler', () => {
40
39
entry : expect . stringContaining ( 'function.test.handler1.ts' ) , // Automatically finds .ts handler file
41
40
} ) ) ;
42
41
43
- expect ( stack ) . toHaveResource ( 'AWS::Lambda::Function' , {
42
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
44
43
Handler : 'index.handler' ,
45
44
Runtime : 'nodejs14.x' ,
46
45
} ) ;
@@ -155,7 +154,7 @@ test('configures connection reuse for aws sdk', () => {
155
154
// WHEN
156
155
new NodejsFunction ( stack , 'handler1' ) ;
157
156
158
- expect ( stack ) . toHaveResource ( 'AWS::Lambda::Function' , {
157
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
159
158
Environment : {
160
159
Variables : {
161
160
AWS_NODEJS_CONNECTION_REUSE_ENABLED : '1' ,
@@ -170,8 +169,8 @@ test('can opt-out of connection reuse for aws sdk', () => {
170
169
awsSdkConnectionReuse : false ,
171
170
} ) ;
172
171
173
- expect ( stack ) . toHaveResource ( 'AWS::Lambda::Function' , {
174
- Environment : ABSENT ,
172
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
173
+ Environment : Match . absent ( ) ,
175
174
} ) ;
176
175
} ) ;
177
176
@@ -183,7 +182,7 @@ test('NodejsFunction in a VPC', () => {
183
182
new NodejsFunction ( stack , 'handler1' , { vpc } ) ;
184
183
185
184
// THEN
186
- expect ( stack ) . toHaveResource ( 'AWS::Lambda::Function' , {
185
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Function' , {
187
186
VpcConfig : {
188
187
SecurityGroupIds : [
189
188
{
0 commit comments