Cypress component test autoconfig issue with additionalIgnorePattern
See original GitHub issueCurrent behavior
Cypress is already configured to work as e2e testing tool and my cypress.config.ts override the default specPattern to include both cucumber and non cucumber specs:
e2e: {
async setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config)
on(
'file:preprocessor',
createBundler({
plugins: [nodePolyfills(), createEsbuildPlugin(config)],
})
)
},
specPattern: ['tests/e2e/**/*.{feature,features}', 'tests/e2e/**/*.cy.{js,jsx,ts,tsx}'],
viewportHeight: 1080,
viewportWidth: 1920,
},
Problem is that apparently, even though specPattern correctly recognize and accept a list of string, when you try to have cypress autoconfigure the component testing, this is what you get:
Stack trace:
Error: An invalid configuration value was set.
Expected additionalIgnorePattern to be a string.
Instead the value was:
[
"tests/e2e/**/*.{feature,features}",
"tests/e2e/**/*.cy.{js,jsx,ts,tsx}"
]
at /home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/server/lib/config.js:151:23
at /home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/config/src/browser.js:114:24
at /home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/lodash/lodash.js:3032:24)
at /home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/lodash/lodash.js:4936:18
at Function.forEach (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/lodash/lodash.js:9410:14)
at Object.validate (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/config/src/browser.js:108:29)
at mergeDefaults (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/server/lib/config.js:146:17)
at Object.setupFullConfigWithDefaults (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/server/lib/config.js:78:12)
at ProjectConfigManager.buildBaseFullConfig (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/data-context/src/data/ProjectConfigManager.js:279:65)
at ProjectConfigManager.getFullInitialConfig (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/data-context/src/data/ProjectConfigManager.js:322:45)
at ProjectConfigManager.setupNodeEvents (/home/rsaleri/.cache/Cypress/10.2.0/Cypress/resources/app/packages/data-context/src/data/ProjectConfigManager.js:119:28)
Desired behavior
additionalIgnorePattern should work like specPattern, since apparently it’s what’s using to know which paths discard.
Test code to reproduce
Trying to configure the component testing with a vue2 project and this cypress.config.ts trigger the issue
import {defineConfig} from 'cypress'
const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
const nodePolyfills = require('@esbuild-plugins/node-modules-polyfill').NodeModulesPolyfillPlugin
const addCucumberPreprocessorPlugin = require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin
export default defineConfig({
e2e: {
async setupNodeEvents(on, config) {
await addCucumberPreprocessorPlugin(on, config) // to allow json to be produced
// To use esBuild for the bundler when preprocessing
on(
'file:preprocessor',
createBundler({
plugins: [nodePolyfills(), createEsbuildPlugin(config)],
})
)
},
specPattern: ['tests/e2e/**/*.{feature,features}', 'tests/e2e/**/*.cy.{js,jsx,ts,tsx}'],
viewportHeight: 1080,
viewportWidth: 1920,
},
})
Cypress Version
10.2.0, 10.1.0
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Component Testing Config - Cypress Documentation
Component Testing Config. When you launch Cypress for the first time in a project, the app will automatically guide you through setup and...
Read more >Vue Quickstart - Cypress Documentation
Welcome! This tutorial will walk you through creating a Vue app and using Cypress Component Testing to test it. We assume you are...
Read more >What's New with Cypress Web Testing?
Features. Cypress will throw an error when a user attempts to update a configuration value at run-time using either the Test Configuration or...
Read more >Svelte Component Testing - Cypress Documentation
Tutorial. Visit the Svelte Quickstart Guide for a step-by-step tutorial on creating a new Svelte app and adding component tests.
Read more >Troubleshooting | Cypress Documentation
Split large spec files into smaller ones. Split long tests into smaller tests. Run the same test using --browser chrome. The problem might...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rsaleri thank you very much for the report. This is occurring because we set the internal config property
additionalIgnorePattern
to your defined e2especPattern
when you start component testing; we don’t want to accidentally/incorrectly pull in your e2e test files as component test files. However, we’re currently botching the validation here.I reproduced this bug by updating our internal
launchpad
project config to use the following E2E spec pattern below and subsequently trying to launch its component tests.A workaround is to put the entire expanded list in a single string like:
But it’s just that, a workaround.