How to add to the sample datasets used in Cypress testing

I would like to expand on the Metabase Cypress tests to test features that we have modified in our forked version of Metabase. To do so I would like to add pre existing content to the Metabase image when it is built using build-for-test so that we do not use Cypress to create content and instead the content will already be ready to be tested in the image. How do I go about adding to the sample datasets used in testing?

With the use case I describe above, is it better to create the desired content in Metabase, and then take a snapshot of the application database which can then be reused in future tests?
Or, is it better to edit the existing h2 database file (I believe it is resources/sample-dataset.db.mv.db) to have rows pertaining to the content I wish to create?

I'd recommend adding another database alongside resources/sample-dataset.db.mv.db rather than editing it, but both might work depending on what changes you need.

If you add another database, you'll need to add it to the Metabase instance before your tests run. Here's an example of where we do that. That "snapshot" creates a sql file that overwrites the app db before your test runs. Each call to restore triggers that.

I'll send you an email to discuss more.

1 Like