bigbite / wp-cypress

WordPress end to end testing with Cypress.io.
MIT License
86 stars 19 forks source link

Set up as GH action #49

Closed KevinBatdorf closed 3 years ago

KevinBatdorf commented 3 years ago

Describe the solution you'd like I'm looking for a solution to automate testing of a WP plugin in a GitHub action.

Ideally, The repo would be of the plugin files only and it would install WP around it, set up the server, etc.

Has anyone set this up before?

liamdefty commented 3 years ago

Hi @KevinBatdorf

We've done this before, so definitely achievable and doesn't require too much work if you're using this tool.

First set your configuration in cypress.json to be something similar to below ensuring the path to the plugin you want to test is correct.

{
 "wp": {
    "version": ["5.5"],
    "plugins": ["./"]
  }
}

Then you can use Cypress's GitHub action https://github.com/cypress-io/github-action to get most of the way there. But you need to ensure the test container is running. We've done something similar below in a workflow:

      - name: Yarn Install
        uses: cypress-io/github-action@v1
        with:
          # just perform install
          runTests: false

      - name: WP Cypress Start
        run: yarn run wp-cypress start

      - name: Run Cypress
        uses: cypress-io/github-action@v1
        with:
          browser: chrome
          headless: true
          install: false

We hope to provide some examples of testing on different CI's in the future but hope this helps for now 🤞🏽