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

Plugin @cypress/grep 3.1.5 throwing Cypress configuration error on cypress run #27216

Closed
zedconte opened this issue Jul 5, 2023 · 11 comments · Fixed by #27231
Closed

Plugin @cypress/grep 3.1.5 throwing Cypress configuration error on cypress run #27216

zedconte opened this issue Jul 5, 2023 · 11 comments · Fixed by #27231
Assignees

Comments

@zedconte
Copy link

zedconte commented Jul 5, 2023

Current behavior

I am getting this next configuration error when running cypress tests using plugin @cypress/grep 3.1.5. The cypress tests used to work correctly but now when running I am unable to execute the browser.

image

TypeError

Your configFile threw an error from: /Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js

The error was thrown while executing your e2e.setupNodeEvents() function:

_node_modules/fast-glob/out/utils/pattern.js:131:21_

> 129  | exports.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern; 
> 130  | function expandPatternsWithBraceExpansion(patterns) {
> 131  |     return patterns.reduce((collection, pattern) => {
>        |                   ^
> 132 |         return collection.concat(expandBraceExpansion(pattern));
> 133 |     }, []);
> 134 | }
> 135 | exports.expandPatternsWithBraceExpansion = expandPatternsWithBraceExpansion;

### Stacktrace:
`TypeError: patterns.reduce is not a function
    at Object.expandPatternsWithBraceExpansion (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/utils/pattern.js:131:21)
    at processPatterns (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:27:34)
    at Object.generate (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:7:20)
    at getWorks (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:91:31)
    at AsyncFunction.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:23:23)
    at AsyncFunction.module.exports.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/globby/index.js:151:42)
    at cypressGrepPlugin (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/@cypress/grep/src/plugin.js:70:30)
    at setupNodeEvents (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js:20:39)
    at /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14
    at tryCatcher (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)
    at RunPlugins.load (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)
    at RunPlugins.runSetupNodeEvents (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)
    at EventEmitter. (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)
    at EventEmitter.emit (node:events:513:28)
    at EventEmitter.emit (node:domain:489:12)
    at process. (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:513:28)
    at process.emit (node:domain:489:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:946:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21)`

cypress.config.js

const { defineConfig } = require("cypress");

module.exports = defineConfig({
	reporter: 'junit',
	reporterOptions: {
		mochaFile: 'results/api-test-results-[hash].xml',
		toConsole: true,
	},
	e2e: {
		baseUrl: "http://localhost:8080",
		setupNodeEvents(on, config) {
			require('@cypress/grep/src/plugin')(config);
			on('task', {
				log(message) {
					console.log(message)
					return null;
				},
			});
			return config;
		},
	},

Desired behavior

Cypress is able to start and run tests normally

Test code to reproduce

https://github.com/zedconte/cypress-test-tiny

Cypress Version

12.16.0

Node version

v16.20.1

Operating System

macOS 13.4

Debug Logs

cypress:lifecycle:child:RunPlugins:54440 plugins file errored: TypeError: patterns.reduce is not a function
    at Object.expandPatternsWithBraceExpansion (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/utils/pattern.js:131:21)
    at processPatterns (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:27:34)
    at Object.generate (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:7:20)
    at getWorks (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:91:31)
    at AsyncFunction.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:23:23)
    at AsyncFunction.module.exports.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/globby/index.js:151:42)
    at cypressGrepPlugin (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/@cypress/grep/src/plugin.js:70:30)
    at setupNodeEvents (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js:20:39)
    at /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14
    at tryCatcher (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)
    at RunPlugins.load (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)
    at RunPlugins.runSetupNodeEvents (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)
    at EventEmitter.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)
    at EventEmitter.emit (node:events:513:28)
    at EventEmitter.emit (node:domain:489:12)
    at process.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:513:28)
    at process.emit (node:domain:489:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:946:14)
    at processTicksAndRejections (node:internal/process/task_queues:84:21) +87ms
  cypress:lifecycle:ProjectConfigManager catch setupNodeEvents { name: 'Error', message: 'Your \x1B[95mconfigFile\x1B[39m threw an error from: \x1B[94m/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js\x1B[39m\n' + '\n' + 'The error was thrown while executing your \x1B[33me2e.setupNodeEvents()\x1B[39m function:', stack: 'TypeError: patterns.reduce is not a function\n' + '    at Object.expandPatternsWithBraceExpansion (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/utils/pattern.js:131:21)\n' + '    at processPatterns (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:27:34)\n' + '    at Object.generate (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:7:20)\n' + '    at getWorks (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:91:31)\n' + '    at AsyncFunction.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:23:23)\n' + '    at AsyncFunction.module.exports.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/globby/index.js:151:42)\n' + '    at cypressGrepPlugin (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/@cypress/grep/src/plugin.js:70:30)\n' + '    at setupNodeEvents (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js:20:39)\n' + '    at /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14\n' + '    at tryCatcher (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)\n' + '    at Function.Promise.attempt.Promise.try (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)\n' + '    at RunPlugins.load (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)\n' + '    at RunPlugins.runSetupNodeEvents (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)\n' + '    at EventEmitter.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)\n' + '    at EventEmitter.emit (node:events:513:28)\n' + '    at EventEmitter.emit (node:domain:489:12)\n' + '    at process.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:513:28)\n' + '    at process.emit (node:domain:489:12)\n' + '    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)\n' + '    at emit (node:internal/child_process:946:14)\n' + '    at processTicksAndRejections (node:internal/process/task_queues:84:21)', type: 'CONFIG_FILE_SETUP_NODE_EVENTS_ERROR', details: 'TypeError: patterns.reduce is not a function\n' + '    at Object.expandPatternsWithBraceExpansion (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/utils/pattern.js:131:21)\n' + '    at processPatterns (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:27:34)\n' + '    at Object.generate (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:7:20)\n' + '    at getWorks (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:91:31)\n' + '    at AsyncFunction.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:23:23)\n' + '    at AsyncFunction.module.exports.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/globby/index.js:151:42)\n' + '    at cypressGrepPlugin (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/@cypress/grep/src/plugin.js:70:30)\n' + '    at setupNodeEvents (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js:20:39)\n' + '    at /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14\n' + '    at tryCatcher (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)\n' + '    at Function.Promise.attempt.Promise.try (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)\n' + '    at RunPlugins.load (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)\n' + '    at RunPlugins.runSetupNodeEvents (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)\n' + '    at EventEmitter.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)\n' + '    at EventEmitter.emit (node:events:513:28)\n' + '    at EventEmitter.emit (node:domain:489:12)\n' + '    at process.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:513:28)\n' + '    at process.emit (node:domain:489:12)\n' + '    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)\n' + '    at emit (node:internal/child_process:946:14)\n' + '    at processTicksAndRejections (node:internal/process/task_queues:84:21)', isCypressErr: true, messageMarkdown: 'Your `configFile` threw an error from: `/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js`\n' + '\n' + 'The error was thrown while executing your `e2e.setupNodeEvents()` function:', originalError: { name: 'TypeError', message: 'patterns.reduce is not a function', stack: 'TypeError: patterns.reduce is not a function\n' + '    at Object.expandPatternsWithBraceExpansion (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/utils/pattern.js:131:21)\n' + '    at processPatterns (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:27:34)\n' + '    at Object.generate (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/managers/tasks.js:7:20)\n' + '    at getWorks (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:91:31)\n' + '    at AsyncFunction.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/fast-glob/out/index.js:23:23)\n' + '    at AsyncFunction.module.exports.sync (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/globby/index.js:151:42)\n' + '    at cypressGrepPlugin (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/node_modules/@cypress/grep/src/plugin.js:70:30)\n' + '    at setupNodeEvents (/Users/raulortega/Documents/Current/code/STAGING/platform-shell/mfe-api-tests/cypress-local.config.js:20:39)\n' + '    at /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14\n' + '    at tryCatcher (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)\n' + '    at Function.Promise.attempt.Promise.try (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)\n' + '    at RunPlugins.load (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)\n' + '    at RunPlugins.runSetupNodeEvents (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)\n' + '    at EventEmitter.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)\n' + '    at EventEmitter.emit (node:events:513:28)\n' + '    at EventEmitter.emit (node:domain:489:12)\n' + '    at process.<anonymous> (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)\n' + '    at process.emit (node:events:513:28)\n' + '    at process.emit (node:domain:489:12)\n' + '    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)\n' + '    at emit (node:internal/child_process:946:14)\n' + '    at processTicksAndRejections (node:internal/process/task_queues:84:21)' } } +1s
  cypress:server:saved_state making saved state from /Users/raulortega/Library/Caches/Cypress/12.16.0/Cypress.app/Contents/Resources/app/packages/server +1s

Other

No changes in dependencies were done, so far just tried updating npm and node version from 16.20.0 to 16.20.1 but that didn't solve the issue.

Another clone repo is working fine and I haven't made any changes to the code.

@KarmaCop213
Copy link

Having the same problem.

"cypress": "12.11.0",

node v16.20.0

@Hayk-S
Copy link

Hayk-S commented Jul 6, 2023

Same problem:

"cypress": "12.3.0"
node v16.17.0

@neerajdembla-hero
Copy link

Same problem :

"cypress" : 12.9.0
node v18.15.0

@zedconte
Copy link
Author

zedconte commented Jul 6, 2023

My team has found a workaround by just commenting this line in cypress.config.js
//require('@cypress/grep/src/plugin')(config);

Hopefully that helps in the meantime but we need a long term solution.

@neerajdembla-hero
Copy link

@zedconte Thanks for your suggestion, I was wondering if we comment this line can we still use cypress/grep to run tests based on some tags ?

@Hayk-S
Copy link

Hayk-S commented Jul 6, 2023

@neerajdembla-hero no, once you comment out the line, you can't use grep

@neerajdembla-hero
Copy link

Thanks @Hayk-S I was trying to use grep only for tags, is there any alternate solution you can suggest for short term ?
Thanks in advance

@samtsai
Copy link
Contributor

samtsai commented Jul 6, 2023

The issue might be in fast-glob.

A temporary workaround is to add a resolution range of: fast-glob at 3.2.12 to your package.json (credit to @memodi mrmlnc/fast-glob#404 (comment))

"resolutions": {
    "fast-glob": ">=3.2.9 <=3.2.12"
}

@cypress/grep could also look at making any necessary code changes to work with 3.3.0.

@ivan-verges
Copy link

This issue is caused by the new version of the fast-glob package (3.3.0).
To get a workaround, add manually this dependency to your packages.json file:
"fast-glob": "3.2.12"

@zedconte
Copy link
Author

zedconte commented Jul 6, 2023

Thank you for the workaround @ivan-verges & @samtsai , this will do while the newest fast-glob could be patched

@MikeMcC399
Copy link
Contributor

Note the comment in mrmlnc/fast-glob#404:

The public interface of this package does not support a string as the value for the ignore option since 2018 year (release). I do not consider this issue a bug in my package. It is a problem on the consumer side.

Right now the problem needs to be fixed on the cypress side.

Similar issues: mrmlnc/fast-glob#403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants