diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 8d9d451aba83..572dbb896879 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -24,6 +24,10 @@ _Released 4/23/2024_ - Fixed a regression introduced in [`13.6.0`](https://docs.cypress.io/guides/references/changelog#13-6-0) where Cypress would occasionally exit with status code 1, even when a test run was successful, due to an unhandled WebSocket exception (`Error: WebSocket connection closed`). Addresses [#28523](https://github.com/cypress-io/cypress/issues/28523). - Fixed an issue where Cypress would hang on some commands when an invalid `timeout` option was provided. Fixes [#29323](https://github.com/cypress-io/cypress/issues/29323). +**Bugfixes:** + + - Specs with () in the filename will no longer fail to load and now behave as any other spec when run with the `--spec` argument via `cypress run`. Fixes [#28509](https://github.com/cypress-io/cypress/issues/28509). + **Misc:** - `.its()` type now excludes null and undefined. Fixes [#28872](https://github.com/cypress-io/cypress/issues/28872). diff --git a/packages/server/lib/util/args.js b/packages/server/lib/util/args.js index f948f709c82e..64042402e839 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -234,6 +234,9 @@ const parseSpecArgv = (pattern) => { ] } + // Escape parentheses. + pattern = pattern.replace(/[()]/g, '\\$&') + /** * Sanitizes a path's leftover commas. * diff --git a/packages/server/test/unit/util/args_spec.js b/packages/server/test/unit/util/args_spec.js index ff7e1ba4af00..c930ad590bae 100644 --- a/packages/server/test/unit/util/args_spec.js +++ b/packages/server/test/unit/util/args_spec.js @@ -216,6 +216,13 @@ describe('lib/util/args', () => { expect(options.spec[2]).to.eq(`${getCwd()}/cypress/integration/foo2/bar/baz/test.ts`) expect(options.spec[3]).to.eq(`${getCwd()}/cypress/integration/foo3/bar/baz/foo4.ts`) }) + + // https://github.com/cypress-io/cypress/issues/28509 + it('correctly escapes parentheses in filename', function () { + const options = this.setup('--spec', 'cypress/integration/foo/bar/test().ts') + + expect(options.spec[0]).to.eq(`${getCwd()}/cypress/integration/foo/bar/test\\(\\).ts`) + }) }) context('--tag', () => {