diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index b6f1a1d2e274..3a0a5a3a5455 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,6 +6,7 @@ _Released 7/2/2024 (PENDING)_ **Bugfixes:** - Fixed an issue where Firefox 129 (Firefox Nightly) would not launch with Cypress. Fixes [#29713](https://github.com/cypress-io/cypress/issues/29713). Fixed in [#29720](https://github.com/cypress-io/cypress/pull/29720). +- 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). **Dependency Updates:** @@ -117,7 +118,7 @@ _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). - + **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..4729b24e335f 100644 --- a/packages/server/lib/util/args.js +++ b/packages/server/lib/util/args.js @@ -234,6 +234,17 @@ const parseSpecArgv = (pattern) => { ] } + // Split the path into directory and file name + const lastSlashIndex = pattern.lastIndexOf('/') + const directoryPath = pattern.substring(0, lastSlashIndex + 1) + const fileName = pattern.substring(lastSlashIndex + 1) + + // Escape the parentheses in the file name + const escapedFileName = fileName.replace(/[()]/g, '\\$&') + + // Recombine the directory path and escaped file name + pattern = directoryPath + escapedFileName + /** * 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', () => {