0

i'm using loopback-4, Any idea how to mock any service call while running e2e test? like db service or token service etc. i know we can mock unit test using sinon, but is it possible to mock any service in e2e?

Timofey Stolbov
  • 4,501
  • 3
  • 40
  • 45
ni-met
  • 23
  • 3

1 Answers1

0

Although, not the best approach but for the APIs you can use things like nock: https://github.com/nock/nock
Ideally, you should mock the http client but that might be quite difficult in loopback.

For databases I'd recommend spinning up a local dockerized database and make requests to it, because it allows testing your migrations as well. But if you really don't want to make db calls: for v2 and v3 of the framework I used to use the in-memory datasource specifically for tests, in-memory here means the exact datasource type when you create new one.

mcm
  • 56
  • 4