0

I want to test the loopback endpoints with mocha, like this example that comes with loopback This example, but when I instantiate the main class I am using the datasource that was injected in each repository, but just for testing with mocha I want to change the repositories datasource to an in-memory datasource

So how can I change this injection for an in-memory datasource just at the moment i type npm test

  constructor(
@inject('datasources.Schedule') dataSource: ScheduleDataSource,
Gabriel-BS
  • 11
  • 1
  • You will need to be more explicit about what the actual issue is. Can you provide a minimal verifiable example or perhaps show the code that you wrote that isn't working? [Read How to Ask for more details.](https://stackoverflow.com/questions/how-to-ask) – MichaelD Aug 12 '19 at 21:43

2 Answers2

0

You can find how to setup a test datasource for test in lb4: Testing-your-application

Zhikai Xiong
  • 357
  • 2
  • 9
0

Open the repositories folder, open any of the repository file you have listed. You will see an import where the datasource is imported from, just change it to read from your new datasource.

vhiktordom
  • 173
  • 2
  • 11