Skip to content

A test-driven template for building reliable Strapi v5 plugins

License

Notifications You must be signed in to change notification settings

pluginpal/strapi-plugin-boilerplate

Repository files navigation

Strapi v5 Plugin Boilerplate

A test-driven template for building reliable Strapi v5 Plugins
CI build status

✨ Features

  • Setup using @strapi/sdk-plugin with commands for build and watch.
  • An isolated Strapi instance for testing and development, the Playground.
  • Github Actions workflow for linting and testing.
  • Clear community files like CONTRIBUTING.md and CODE-OF-CONDUCT.md.
  • Jest & Supertest for testing your plugin API's.
  • Cypress for GUI e2e tests

⏳ How to use

This repository is meant to be a template for new plugins. It can be used as a starting point, giving you the resources to built a test-driven Strapi v5 plugin.

After creating your copy of the template, do a find-replace through the code and change the following:

  1. Change boilerplate (lowercase) to be the identifier of your plugin.
  2. Change Boilerplate (uppercase) to be the human readable name of your plugin.

You're all set! Go make your plugin and write some tests!

📓 Tutorials

This repository has been made alongside an article series called "Automated Testing for Strapi v5 Plugins". To better understand how and why this repository has been setup, please read the following articles:

  1. Using a Playground Instance
  2. Testing the API's
  3. E2E tests (In Progress)

🔌 Commands

Strapi Plugin SDK commands

  1. yarn build
  1. yarn watch
  1. yarn watch:link
  1. yarn verify

Testing commands

  1. yarn test:ts:front
  • A check for Typescript errors on the front-end side.
  • Used in the lint step of the pipeline.
  1. yarn test:ts:back
  • A check for Typescript errors on the back-end side.
  • Used in the lint step of the pipeline.
  1. yarn test:jest
  • Runs the jest tests. Can contain unit & integration tests.
  • Used in the test step of the pipeline.
  1. yarn test:cypress
  • Runs the cypress tests. Contains e2e tests.
  • Used in the test step of the pipeline.
  1. yarn test:cypress:open
  • Opens the cypress GUI.

Playground commands

  1. yarn playground:install
  • Installs the plugin into the playground using yalc-add-link.
  • Installs all other dependencies of the playground.
  1. yarn playground:yalc-add
  • Installs a production-like version of the plugin, into the playground.
  1. yarn playground:yalc-add-link
  • Installs a development build of the plugin, into the playground.
  1. yarn playground:build
  1. yarn playground:develop
  1. yarn playground:start

About

A test-driven template for building reliable Strapi v5 plugins

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project