Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cypress 10.0 renamed ignoreTestFiles to excludeSpecPattern but @nrwl/cypress wasn't updated #13860

Closed
jethrolarson opened this issue Dec 16, 2022 · 8 comments · Fixed by #13942
Assignees
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug

Comments

@jethrolarson
Copy link

jethrolarson commented Dec 16, 2022

Current Behavior

specifying ignoreTestFiles or excludeSpecPattern in configurations does nothing on cypress >= 10.0

Expected Behavior

either ignoreTestFiles should work or excludeSpecPattern should work.

from project.json

"targets": {
    "e2e": {
      "executor": "@nrwl/cypress:cypress",
      "options": {
        "cypressConfig": "apps/foobar/cypress.config.ts",
        "devServerTarget": "website:serve",
        "testingType": "e2e"
      },
      "configurations": {
        "production": {
          "baseUrl": "https://foo.bar",
          "devServerTarget": "",
          "excludeSpecPattern": "**/preprod/**/*"
          "ignoreTestFiles": "**/preprod/**/*",
        },

Github Repo

https://github.com/jethrolarson/nx-examples/tree/master/apps/cart-e2e

Steps to Reproduce

  1. have a e2e test suite setup
  2. create some test file that should be ignored in one of the configurations
  3. specify a glob that would match the test file in ignoreTestFiles and/or excludeSpecPattern in a configuration
  4. run the e2e tests nx e2e my-app-e2e --configuration=myconfig

expected:
matching test is not run

actual:
test is run

Nx Report

Node : 16.13.1
   OS   : darwin x64
   yarn : 1.22.17

   nx : 15.3.3
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.3.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.3.3
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.3.3
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.3.3
   @nrwl/js : 15.3.3
   @nrwl/linter : 15.3.3
   @nrwl/nest : Not Found
   @nrwl/next : 15.3.3
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.3.3
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.3.3
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.3.3
   @nrwl/webpack : 15.3.3
   @nrwl/workspace : 15.3.3
   typescript : 4.8.4

Failure Logs

N/A

Additional Information

Looks like nx/packages/cypress/src/executors/cypress/cypress.impl.ts just needs to be updated to use the new name for that property.

@jethrolarson
Copy link
Author

Relevant change on cypress: https://docs.cypress.io/guides/references/changelog#10-0-0

@jethrolarson
Copy link
Author

jethrolarson commented Dec 16, 2022

here's a workaround that I figured out:

create a separate cypress.config.ts for each configuration you want to be different:

cypress.production.config.ts

import { defineConfig } from 'cypress';
import baseConfig from './cypress.config';
export default defineConfig({
  ...baseConfig,
  e2e: {
    ...baseConfig.e2e,
    excludeSpecPattern: '**/preprod/**/*',
  },
});

Then in the project.json

"configurations": {
        "production": {
          "baseUrl": "https://foo.bar",
          "cypressConfig": "apps/foo-e2e/cypress.production.config.ts",
        },

This is especially useful since @nrwl/cypress is also not passing through the "specPattern" when passed in the configuration.

@jethrolarson
Copy link
Author

jethrolarson commented Dec 16, 2022

If @nrwl/cypress is not going to support all the cypress configuration in the project file maybe it's best to not have partial support, that way devs aren't wasting their time trying to figure out why the configuration is being ignored?

And if properties aren't being passed through, maybe the config should throw?

@FrozenPandaz FrozenPandaz added the scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx label Dec 20, 2022
@barbados-clemens barbados-clemens self-assigned this Dec 20, 2022
@barbados-clemens
Copy link
Contributor

I updated the changes in #13942

but the option is still being ignored by cypress. I'll reach out the Cypress team to see what might be happening there.

@barbados-clemens
Copy link
Contributor

barbados-clemens commented Dec 20, 2022

So in v10 the excludeSpecPattern is now a specific e2e/component level option vs a root level option.
so providing the option in the executor doesn't do anything since it's provided at the root level.

i.e.

export default defineConfig({
  excludeSpecPattern: "" // this doesn't do anything and where cypress executor is adding the option
  e2e: {
    excludeSpecPattern: "" // this is where this is defined
  },
  component: {
    excludeSpecPattern: "" // also can be here
  }
})

@jethrolarson
Copy link
Author

jethrolarson commented Dec 25, 2022

@barbados-clemens Hey, thanks for taking this on <3

So I guess you have to pass-through in both places or remove the override?

It may be worth auditing all the properties passed through as I suspect this isn't the only broken one.

@barbados-clemens
Copy link
Contributor

until PR #13942 is merged in, you'll have to defined them in the cypress config. Without most people out for the holidays it could be a little bit before that PR is able to be reviewed and merged.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants