Help needed with running Cypress for different sites from one codebase

Hello!

We’re using Cypress - the netlify-plugin-cypress package - to run some end-to-end tests on deploy previews.

The problem is that we run multiple sites with different content from one codebase. We have site-specific Cypress tests that, when run on a site other than the one they were intended for, fail.

I’d like to use a variable to change the spec input value, but can’t figure out how to use it in the netlify.toml file.

Example:

Assume we have a site called “example-site”.

We have some universal tests in /cypress/e2e/universal, and some site-specific tests in /cypress/e2e/example-site

In netlify.toml, I’ve tried this:

[context.dev.environment]
  CYPRESS_SPECS = "cypress/e2e/universal/*.cy.ts,cypress/e2e/$SITE_NAME/*.cy.ts"

[[context.dev.plugins]]
  package = "netlify-plugin-cypress"
    [context.dev.plugins.inputs]
    enable = false
    [context.dev.plugins.inputs.preBuild]
    enable = true
    configFile = "cypress.config.ts"
    record = false
    spec = $CYPRESS_SPECS
    start = "next dev"
    wait-on = 'http://localhost:3000'

But it reads $SITE_NAME literally and looks for tests in /cypress/e2e/universal/ (correct) and /cypress/e2e/$SITE_NAME/ (incorrect)

Any ideas?

Try the following.

      spec = "${CYPRESS_SPECS}"
      start = "next dev"
      wait-on = "http://localhost:3000"