This message was deleted.
# typescript
s
This message was deleted.
l
The
setMock
function takes an object that must have a
call
function. This function is where you fake out calls to Pulumi functions.
In this case, it is the way to go.
The docs show where the code goes, but there's no example code: https://www.pulumi.com/docs/guides/testing/unit/#add-mocks
However there is an example of the
aws.ec2.getAmi()
function being faked here: https://github.com/pulumi/examples/blob/947273e7a62cf31649559344b2dd8df78bddacd9/testing-unit-ts/mocha/ec2tests.ts#L44
c
Thanks for the hints but it doesn't seem that the getter can be mocked within the
call
function of the mocks. I logged
args.token
of all invokations to the console and none of them where matching but I still had this error message.
Copy code
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Error: failed to read resource #undefined 'default' [aws:ec2/securityGroup:SecurityGroup]: req.getCustom is not a function".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
Anyway I considered that I do not need to export the whole
securityGroup
just the
securityGroupId
that I already got from the VPC so problem solved. 🙂