Hi I'm struggling with unit testing lambda resourc...
# aws
r
Hi I'm struggling with unit testing lambda resource. Always get error when unit testing stack that have a lambda callbackFunction...
Copy code
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down
      at getStackResource (node_modules/@pulumi/resource.ts:1116:36)
      at new Resource (node_modules/@pulumi/resource.ts:300:39)
      at new CustomResource (node_modules/@pulumi/resource.ts:780:9)
      at new Role (node_modules/@pulumi/iam/role.ts:306:9)
      at Object.construct (node_modules/@pulumi/iam/index.ts:111:24)
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down.
      at node_modules/@pulumi/runtime/closure/createClosure.ts:417:48
      at node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:21:71
      at Object.<anonymous>.__awaiter (node_modules/@pulumi/pulumi/runtime/closure/createClosure.js:17:12)
TypeError: stack.getStackResource is not a function
Copy code
// Lambda
export const func = new aws.lambda.CallbackFunction("test", {
  callback: async (ev, ctx) => {
    return {
      statusCode: 200,
      body: `Hello, world!`,
    };
  },
});