Skip to content
Merged
5 changes: 4 additions & 1 deletion packages/driver/src/cross-origin/origin_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,14 @@ export const handleOriginFn = (Cypress: Cypress.Cypress, cy: $Cy) => {
})

cy.state('onFail', (err) => {
const currentAssertionUserInvocationStack = cy.state('current').get('currentAssertionCommand')?.get('userInvocationStack')
const userInvocationStack = cy.state('current').get('userInvocationStack')

setRunnableStateToPassed()
if (queueFinished) {
// If the queue is already finished, send this event instead because
// the primary won't be listening for 'queue:finished' anymore
Cypress.specBridgeCommunicator.toPrimary('uncaught:error', { err })
Cypress.specBridgeCommunicator.toPrimary('uncaught:error', { err, userInvocationStack, currentAssertionUserInvocationStack })

return
}
Expand Down
20 changes: 18 additions & 2 deletions packages/driver/src/cy/commands/prompt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ const initializeCloudCyPrompt = async (Cypress: Cypress.Cypress, cy: Cypress.Cyp
if (!Cypress.isCrossOriginSpecBridge) {
Cypress.primaryOriginCommunicator.removeAllListeners('prompt:more-info-needed')
Cypress.primaryOriginCommunicator.on('prompt:more-info-needed', ({ testId, logId, onSave, onCancel }: CyPromptMoreInfoNeededOptions) => {
window.getEventManager!().ws.emit('prompt:more-info-needed', { testId, logId, onSave, onCancel })
window.getEventManager!().localBus.emit('prompt:more-info-needed', { testId, logId, onSave, onCancel })
})

Cypress.primaryOriginCommunicator.on('get:source:details:for:line', ({ line, projectRoot }, { origin, responseEvent }) => {
const sourceDetails = $stackUtils.getSourceDetailsForFirstLine(line, projectRoot)

Cypress.primaryOriginCommunicator.toSpecBridge(origin, responseEvent, sourceDetails)
})
}

Expand All @@ -109,7 +115,17 @@ const initializeCloudCyPrompt = async (Cypress: Cypress.Cypress, cy: Cypress.Cyp
extendErrorMessages: $errUtils.extendErrorMessages,
throwErrByPath: $errUtils.throwErrByPath,
},
getSourceDetailsForFirstLine: $stackUtils.getSourceDetailsForFirstLine,
getSourceDetailsForFirstLine: async (line, projectRoot) => {
if (Cypress.isCrossOriginSpecBridge) {
return await Cypress.specBridgeCommunicator.toPrimaryPromise({
event: 'get:source:details:for:line',
data: { line, projectRoot },
timeout: Cypress.config().defaultCommandTimeout,
})
}

return $stackUtils.getSourceDetailsForFirstLine(line, projectRoot)
},
onMoreInfoNeeded: ({ testId, logId, onSave, onCancel }: CyPromptMoreInfoNeededOptions) => {
if (Cypress.isCrossOriginSpecBridge) {
Cypress.specBridgeCommunicator.toPrimary('prompt:more-info-needed', { testId, logId, onSave, onCancel })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export interface CyPromptOptions {
getSourceDetailsForFirstLine: (
stack: string,
projectRoot?: string
) => CyPromptStackLineDetail | undefined
) => CyPromptStackLineDetail | Promise<CyPromptStackLineDetail | undefined> | undefined
onMoreInfoNeeded: (options: CyPromptMoreInfoNeededOptions) => void
}

Expand Down