How to write a unit test with vitest for a function of type StackContext and check sns subscriptions

so basically mode code is like

export function abc({ stack }: StackContext) {
  
  const myTopic = new sns.Topic(stack, 'Topic', {
    displayName: "hello_world",
    topicName: envName(appName)
  })
  if(env == stage){
    myTopic.addSubscription(
      new subscriptions.EmailSubscription("[email protected]")
    )
    myTopic.addSubscription(      
      new subscriptions.EmailSubscription("[email protected]")
    )}

  const testingEnv = env.RANDOM_EMAIL

  if (testEnvironment){
    myTopic.addSubscription(new subscriptions.EmailSubscription(testEnvironment))
  }
}

how would I write unit tests with vitest for this

i tried looking for a bunch of stuff online, but nothing really helped me

Leave a Comment