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

fix: --spec now allows () in filename #29279

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down Expand Up @@ -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).
Expand Down
11 changes: 11 additions & 0 deletions packages/server/lib/util/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 7 additions & 0 deletions packages/server/test/unit/util/args_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down