Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .circleci/cache-version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Bump this version to force CI to re-create the cache from scratch.
9-12-2025
9-15-2025
17 changes: 17 additions & 0 deletions packages/driver/cypress/e2e/commands/prompt/prompt.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
describe('src/cy/commands/prompt', () => {
afterEach(() => {
Cypress.testingType = 'e2e'
})

it('executes the prompt command', () => {
// TODO: (cy.prompt) We will look into supporting other browsers
// as this is rolled out. We will add error messages for other browsers
Expand All @@ -15,4 +19,17 @@ describe('src/cy/commands/prompt', () => {

cy.get('#log').should('contain', 'clicked')
})

it('fails when testingType is component', (done) => {
cy.on('fail', (err) => {
expect(err.message).to.eq('`cy.prompt` is currently only supported in end-to-end tests.')
done()
})

Cypress.testingType = 'component'

cy.visit('http://www.foobar.com:3500/fixtures/prompt.html')

cy.prompt(['Click the "click me" button'])
})
})
26 changes: 26 additions & 0 deletions packages/driver/src/cy/commands/prompt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,31 @@ export default (Commands: Cypress.Cypress['Commands'], Cypress: Cypress.Cypress,
}

Commands.addAll(commands)
} else {
Commands.addAll({
prompt () {
const stack = cy.state('current').get('userInvocationStack')

if (Cypress.testingType === 'component') {
$errUtils.throwErrByPath('prompt.promptTestingTypeError', {
errProps: {
name: 'PromptTestingTypeError',
},
onFail: (err) => {
err.stack = stack
},
})
}

$errUtils.throwErrByPath('prompt.experimentalPromptCommandError', {
errProps: {
name: 'PromptNotEnabledError',
},
onFail: (err) => {
err.stack = stack
},
})
},
})
}
}
8 changes: 8 additions & 0 deletions packages/driver/src/cypress/error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,14 @@ export default {
docsUrl: 'https://on.cypress.io/prompt-download-error',
}
},
promptTestingTypeError: stripIndent`\
\`cy.prompt\` is currently only supported in end-to-end tests.
`,
experimentalPromptCommandError: stripIndent`\
\`cy.prompt\` cannot be called without the \`experimentalPromptCommand\` being set.

Please set this in your Cypress config file to continue using \`cy.prompt\`.
`,
},

proxy: {
Expand Down
70 changes: 70 additions & 0 deletions system-tests/__snapshots__/prompt_spec.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
exports['e2e prompt / fails when experimentalPromptCommand is not set'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (prompt.cy.js) │
│ Searched: cypress/e2e/prompt.cy.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: prompt.cy.js (1 of 1)


prompt
1) should fail when experimentalPromptCommand is not set


0 passing
1 failing

1) prompt
should fail when experimentalPromptCommand is not set:
PromptNotEnabledError: \`cy.prompt\` cannot be called without the \`experimentalPromptCommand\` being set.

Please set this in your Cypress config file to continue using \`cy.prompt\`.
[stack trace lines]




(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 0 │
│ Failing: 1 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: false │
│ Duration: X seconds │
│ Spec Ran: prompt.cy.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Screenshots)

- /XXX/XXX/XXX/cypress/screenshots/prompt.cy.js/prompt -- should fail when experim (1280x720)
entalPromptCommand is not set (failed).png


====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ prompt.cy.js XX:XX 1 - 1 - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) XX:XX 1 - 1 - -


`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
supportFile: false,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('prompt', () => {
it('should fail when experimentalPromptCommand is not set', () => {
cy.prompt(['Click the "click me" button'])
})
})
14 changes: 14 additions & 0 deletions system-tests/test/prompt_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import systemTests from '../lib/system-tests'

describe('e2e prompt', () => {
systemTests.setup()

systemTests.it('fails when experimentalPromptCommand is not set', {
browser: 'electron',
project: 'experimentalPromptCommand',
spec: 'prompt.cy.js',
configFile: 'cypress-disabled-prompt-experiment.config.js',
expectedExitCode: 1,
snapshot: true,
})
})
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32156,7 +32156,7 @@ vitest@2.1.9:
vite-node "2.1.9"
why-is-node-running "^2.3.0"

vitest@3.2.4, vitest@^3.2.4:
vitest@^3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/vitest/-/vitest-3.2.4.tgz#0637b903ad79d1539a25bc34c0ed54b5c67702ea"
integrity sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==
Expand Down
Loading