mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-12 22:41:29 +00:00
fix Cypress component debug hook registration
This commit is contained in:
parent
1fd5c205a9
commit
74755e51d8
2 changed files with 42 additions and 38 deletions
|
|
@ -5,36 +5,36 @@ module.exports = defineConfig({
|
|||
env: {
|
||||
ABS_CYPRESS_DEBUG_BROWSER: false
|
||||
},
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
on('task', {
|
||||
absCypressDebug(payload) {
|
||||
const prefix = `[cypress:${payload.type}]`
|
||||
const message = typeof payload.message === 'string' ? payload.message : JSON.stringify(payload.message)
|
||||
const details = payload.details ? `\n${payload.details}` : ''
|
||||
setupNodeEvents(on, config) {
|
||||
on('task', {
|
||||
absCypressDebug(payload) {
|
||||
const prefix = `[cypress:${payload.type}]`
|
||||
const message = typeof payload.message === 'string' ? payload.message : JSON.stringify(payload.message)
|
||||
const details = payload.details ? `\n${payload.details}` : ''
|
||||
|
||||
// Surface browser-side failures in terminal output for focused debug runs.
|
||||
console.error(`${prefix} ${message}${details}`)
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
on('before:browser:launch', (browser, launchOptions) => {
|
||||
if (!config.env.ABS_CYPRESS_DEBUG_BROWSER) {
|
||||
return launchOptions
|
||||
}
|
||||
|
||||
if (browser.family === 'chromium') {
|
||||
launchOptions.args.push('--auto-open-devtools-for-tabs')
|
||||
launchOptions.args.push('--enable-logging=stderr')
|
||||
launchOptions.args.push('--v=1')
|
||||
}
|
||||
// Surface browser-side failures in terminal output for focused debug runs.
|
||||
console.error(`${prefix} ${message}${details}`)
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
on('before:browser:launch', (browser, launchOptions) => {
|
||||
if (!config.env.ABS_CYPRESS_DEBUG_BROWSER) {
|
||||
return launchOptions
|
||||
})
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
if (browser.family === 'chromium') {
|
||||
launchOptions.args.push('--auto-open-devtools-for-tabs')
|
||||
launchOptions.args.push('--enable-logging=stderr')
|
||||
launchOptions.args.push('--v=1')
|
||||
}
|
||||
|
||||
return launchOptions
|
||||
})
|
||||
|
||||
return config
|
||||
},
|
||||
e2e: {
|
||||
},
|
||||
component: {
|
||||
devServer: {
|
||||
|
|
|
|||
|
|
@ -49,20 +49,24 @@ const forwardBrowserDebug = (type, message, details) => {
|
|||
}, { log: false })
|
||||
}
|
||||
|
||||
window.addEventListener('error', (event) => {
|
||||
forwardBrowserDebug('window-error', event.message || 'Unhandled window error', event.error)
|
||||
})
|
||||
if (!window.__absCypressDebugListenersRegistered) {
|
||||
window.addEventListener('error', (event) => {
|
||||
forwardBrowserDebug('window-error', event.message || 'Unhandled window error', event.error)
|
||||
})
|
||||
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
const reason = event.reason
|
||||
const message = reason?.message || 'Unhandled promise rejection'
|
||||
forwardBrowserDebug('unhandledrejection', message, reason)
|
||||
})
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
const reason = event.reason
|
||||
const message = reason?.message || 'Unhandled promise rejection'
|
||||
forwardBrowserDebug('unhandledrejection', message, reason)
|
||||
})
|
||||
|
||||
Cypress.on('fail', (error, runnable) => {
|
||||
forwardBrowserDebug('cypress-fail', `${runnable?.fullTitle?.() || 'Unknown test'} failed`, error)
|
||||
throw error
|
||||
})
|
||||
Cypress.on('fail', (error, runnable) => {
|
||||
forwardBrowserDebug('cypress-fail', `${runnable?.fullTitle?.() || 'Unknown test'} failed`, error)
|
||||
throw error
|
||||
})
|
||||
|
||||
window.__absCypressDebugListenersRegistered = true
|
||||
}
|
||||
|
||||
//Cypress.Commands.add('mount', mount)
|
||||
Cypress.Commands.add('mount', (component, options = {}) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue