Hey everyone, can someone help me with setting up ...
# help
a
Hey everyone, can someone help me with setting up jest with SST? I managed to setup and create int test for my main stacks but when try to run my unit tests I get fellowing error:
I assume that I should mock my db client somehow but Im struggling with finding some docs or tutorials on how to do that. I would highly appreciate some help @Frank @Jay! 😄
d
I’m not exactly sure about your use case but if I was to mock in jest, generally, I’d do so like this
Copy code
jest.mock('data-api-client', () => ({
  // each of these would the functions on db.
  get: () => ({ some=mock-object-your-client-returns }),
  set: //...
})
f
Thanks @Devin!
@Aleksa Miseljic you can either mock as Devin shared, or if you want to connect to real db, you’d make sure the
process.env.SECRET_ARN
exists in the testing environment.
You can set them in ur tests directly like suggested here https://stackoverflow.com/a/48042799