WebDriver Tests: Mock queries data

  • Goal: I want to test my modules and apps without side effects ie actual database/API queries.

  • Details: the usual way I would go about this is mocking the query response and then evaluating how the frontend reacts to the mocked data

I am currently starting to set up web driver testing for our apps and modules. So far I have not found a way to disable queries in a way that I can inject mock/fake data and results into the module and application. Is there some documentation I have missed? What are the best practices when it comes to testing a retool application or module

  • can I test modules in isolation or do I always need to embed them in an app?

Thanks!

Hi Mods, eg @Tess -> any answer here would be appreciated. How can I test retool applications without actually sending queries to my ressources?

Hi @perelin ,

Thank you for reaching out! While there isn’t a native way to create mock data without calling the actual endpoint, there are workarounds to help you achieve the functionality you're looking for. Here’s what I recommend, so you don’t need to overwrite your endpoint's functionality:

  1. Create a testing environment: Configure the new environment to point to a mock API or testing endpoint. For the purposes of this example, I used example.com. You can also generate your own API using this REST API Generator: REST API Generator.

  2. In your web app: Select the testing environment you’ve created.

  3. Add your mock data: You can return it by using the "Transform Results" option:
    Screenshot 2024-09-17 at 1.47.14 PM

Regarding modules, you can test them in isolation the same way you would test a web app. You can modules either from the module itself or from the parent app.

Additionally, I agree that having this feature natively would be extremely helpful. I’ve submitted a request internally, and our team will notify you once it’s implemented.

1 Like