Bypass the config/database.js file on Strapi instance

Hello :wave:
Basically I’m creating a unit testing plugin for strapi so that all the steps in the Unit Testing article in the Documentation can just be made in one plugin install.

What I would like to automate is the test database setup: currently you have to add in the config/database.js a separate database for testing that will work when the ENV variable is in testing or something like that. I would like to get rid of that step so that config/database.js does not have to be modified just for the unit testing (and is where I’m currently stuck).

My best guess on how to do that is to somehow overwrite the config/database.js when I’m instantiating Strapi for the unit tests:

// Instantiating Strapi for the unit tests
async function setupStrapi() {
  if (!instance) {
    await Strapi().load(); // somehow take my database and not the one in config/database.js
    instance = strapi; 
    await instance.app
      .use(instance.router.routes())
      .use(instance.router.allowedMethods());

    instance.server = http.createServer(instance.app.callback());
  }
  return instance;
}

Anyone has an idea on how to do that?
or any other clue on how the unit test database could be configured from a plugin without having to manually add it to config/database.js?

Is it even a good idead to try to isolate everything in a plugin?

Any feedback will be very welcome,
thanks for reading