This message was deleted.
# typescript
s
This message was deleted.
w
Mocking support was added very recently in https://github.com/pulumi/pulumi/pull/3738. Documentation and examples for mocking using the improvements in that PR are coming soon. @tall-librarian-49374 is working on some content around this. In the meantime - this gist may help? https://gist.github.com/pgavlin/8904a129d1c5e826606ca8482b6386bd#file-ec2tests-js
👍 1
g
Thanks for that, the examples are useful, but I'm struggling a bit with the
call
Mock. From the type definition I see:
Copy code
* @param token: The token that indicates which function is being called. This token is of the form "package:module:function".
And I have a mock like:
Copy code
pulumi.runtime.setMocks({
    call(token: string, args: any, provider?: string): any {
        if (token === "aws:iam:getPolicyDocument") {
            return {args};
        }
    },
    newResource(type: string, name: string, inputs: any, provider?: string, id?: string): any {
        return undefined
    }
});
But I'm not sure if I'm setting the token correctly. The type definition says `
Copy code
call mocks provider-implemented function calls (e.g. aws.get_availability_zones).
But that doesn't seem to match the format in the
@param
statement.
Also, the TypeScript
Mock
requires both
call
and
newResource
to be set, even though I'm not using
newResource
for my test.
Does anyone have an example
call
Mock they can point me to, especially a TypeScript one?