diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 4222088a15b..71b91fa54bd 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -3,6 +3,10 @@ _Released 2/25/2025 (PENDING)_ +**Features:** + + - Add `log: boolean` option to hide the `cy.origin()` log. Addressed in [#31114](https://github.com/cypress-io/cypress/pull/31114). + ## 14.0.3 _Released 2/11/2025_ diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index 07b95291c36..20bfd9e48cb 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -1663,7 +1663,7 @@ declare namespace Cypress { * expect(foo).to.equal('foo') * }) */ - origin(urlOrDomain: string, options: { + origin(urlOrDomain: string, options: Partial & { args: T }, fn: (args: T) => void): Chainable diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index d4a38fb6198..7795afb1d1a 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -1012,6 +1012,8 @@ namespace CypressOriginTests { cy.origin('example.com', { args: 'value' }, (value: string) => { }) cy.origin('example.com', { args: 1 }, (value: number) => { }) cy.origin('example.com', { args: true }, (value: boolean) => { }) + cy.origin('example.com', { args: true, log: true }, (value: boolean) => { }) + cy.origin('example.com', { args: true, log: false }, (value: boolean) => { }) cy.origin() // $ExpectError cy.origin('example.com') // $ExpectError diff --git a/packages/driver/src/cy/commands/origin/index.ts b/packages/driver/src/cy/commands/origin/index.ts index 9661d5a4dc8..3d00e3bad78 100644 --- a/packages/driver/src/cy/commands/origin/index.ts +++ b/packages/driver/src/cy/commands/origin/index.ts @@ -25,7 +25,7 @@ const normalizeOrigin = (urlOrDomain) => { return $Location.normalize(origin) } -type OptionsOrFn = { args: T } | (() => {}) +type OptionsOrFn = (Partial & { args: T }) | (() => {}) type Fn = (args?: T) => {} export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: StateFunc, config: Cypress.InternalConfig) => { @@ -57,6 +57,7 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State callbackFn = optionsOrFn options = { args: undefined, + log: undefined, } } @@ -67,6 +68,7 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State type: 'parent', message: urlOrDomain, timeout, + log: !(options.log === false), // @ts-ignore TODO: revisit once log-grouping has more implementations }, (_log) => { log = _log