mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-26 21:31:31 +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: {
|
env: {
|
||||||
ABS_CYPRESS_DEBUG_BROWSER: false
|
ABS_CYPRESS_DEBUG_BROWSER: false
|
||||||
},
|
},
|
||||||
e2e: {
|
setupNodeEvents(on, config) {
|
||||||
setupNodeEvents(on, config) {
|
on('task', {
|
||||||
on('task', {
|
absCypressDebug(payload) {
|
||||||
absCypressDebug(payload) {
|
const prefix = `[cypress:${payload.type}]`
|
||||||
const prefix = `[cypress:${payload.type}]`
|
const message = typeof payload.message === 'string' ? payload.message : JSON.stringify(payload.message)
|
||||||
const message = typeof payload.message === 'string' ? payload.message : JSON.stringify(payload.message)
|
const details = payload.details ? `\n${payload.details}` : ''
|
||||||
const details = payload.details ? `\n${payload.details}` : ''
|
|
||||||
|
|
||||||
// Surface browser-side failures in terminal output for focused debug runs.
|
// Surface browser-side failures in terminal output for focused debug runs.
|
||||||
console.error(`${prefix} ${message}${details}`)
|
console.error(`${prefix} ${message}${details}`)
|
||||||
return null
|
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')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
on('before:browser:launch', (browser, launchOptions) => {
|
||||||
|
if (!config.env.ABS_CYPRESS_DEBUG_BROWSER) {
|
||||||
return launchOptions
|
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: {
|
component: {
|
||||||
devServer: {
|
devServer: {
|
||||||
|
|
|
||||||
|
|
@ -49,20 +49,24 @@ const forwardBrowserDebug = (type, message, details) => {
|
||||||
}, { log: false })
|
}, { log: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('error', (event) => {
|
if (!window.__absCypressDebugListenersRegistered) {
|
||||||
forwardBrowserDebug('window-error', event.message || 'Unhandled window error', event.error)
|
window.addEventListener('error', (event) => {
|
||||||
})
|
forwardBrowserDebug('window-error', event.message || 'Unhandled window error', event.error)
|
||||||
|
})
|
||||||
|
|
||||||
window.addEventListener('unhandledrejection', (event) => {
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
const reason = event.reason
|
const reason = event.reason
|
||||||
const message = reason?.message || 'Unhandled promise rejection'
|
const message = reason?.message || 'Unhandled promise rejection'
|
||||||
forwardBrowserDebug('unhandledrejection', message, reason)
|
forwardBrowserDebug('unhandledrejection', message, reason)
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.on('fail', (error, runnable) => {
|
Cypress.on('fail', (error, runnable) => {
|
||||||
forwardBrowserDebug('cypress-fail', `${runnable?.fullTitle?.() || 'Unknown test'} failed`, error)
|
forwardBrowserDebug('cypress-fail', `${runnable?.fullTitle?.() || 'Unknown test'} failed`, error)
|
||||||
throw error
|
throw error
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.__absCypressDebugListenersRegistered = true
|
||||||
|
}
|
||||||
|
|
||||||
//Cypress.Commands.add('mount', mount)
|
//Cypress.Commands.add('mount', mount)
|
||||||
Cypress.Commands.add('mount', (component, options = {}) => {
|
Cypress.Commands.add('mount', (component, options = {}) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue