Feedback wanted: Automated Testing Plugin

Hello,

It has felt pretty odd to do automated testing compared to how easy is the GraphQL or Media library integration in Strapi. So I wanted to match the simplisity and efficiency of the official Strapi plugins by creating a community plugin for automated testing.

The goal was to skip the “Do it yourself” approach of the documentation and bundle all of that in a plugin.

But why stop there? How many things can be automated so that after installing the plugin we can jump strait to the business code and not spend time with config or boilerplate?

Well, dad iz deu question (“That is the question” but with french accent).

Currenlty the plugin (a.k.a. Proof-of-Concept) does (link below):

  • Bundles all the dependencies in one plugin (no need to install jest, sqlite or supertest)
  • Automatically creates the __tests__ folder with a __config__ folder inside of it that contains the jest.config.js and the database.js (so all the things related to testing are in that one folder)
  • When running the tests it will automatically replace the config/database.js for the __tests__/__config__/database.js so your testing database is not mixed with the real database config
  • Automatically create a folder for each API endpoint (and create new ones later if added) (e.g. __test__/restaurants/restaurants.test.js)

Things it could potentially do:

  • Test coveradge command out-of-the-box
  • Pre-commit testing out-of-the-box
  • Helper functions to create Admins, SuperAdmins and other Strapi related stuff
  • Putting all depencencies in devDependencies (including the plugin itself) so that nothing of the testing environment gets in the way in production
  • We have the schema of each endpoint so we could do cool things with it too

So the question: is this usefull? would someone use this? should I botter making it better and maintained it?

If yes, should it be with all the automation stuff or just stick to what the documentation tells you to do?

Here is the Github Repo and the strapi-plugin-testing npm package (hit me up if you want the name back :joy:). I have just tested it on my machine so have low expectations. Its running the tests slowly because is not proprely configured (POC).

Be harsh and honest in you comments please (about the idea, not the code), thank you for reading

1 Like

Your good :stuck_out_tongue:

1 Like

Honestly looking forward to where you can take this, I hate even looking at tests, let alone writing them (or debugging the unit-tests guide which needs a massive refactoring).

:+1:

1 Like

Thanks, I will push it a little bit more so is stable enough to be used by anyone, to see if it is usefull or not.

Can you give my some hints on how to improuve it?
specially with how Strapi is instantiated (setupStrapi) so it could lunch faster (maybe by not loading anything related to admin or something like that)

Sorry I was referring to: Unit Testing - Strapi Developer Documentation in our documentation for refactoring, not your plugin idea.