mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-11 17:50:01 -06:00
* develop: feat: gray out the path to system node in cypress run header (#20121) feat: redesign server errors (#20072) test: fix awesome-typescript-loader test and remove test-binary job (#20131) fix: Fix issues with stack traces and command log in Chrome 99 (#20049) fix: `cy.type(' ')` fires click event on button-like elements. (#20067) fix: `change`, `input` events are not fired when the same option is selected again. (#19623) build: publish vue3 on latest (#20099) chore: release @cypress/webpack-preprocessor-v5.11.1 chore: release @cypress/webpack-dev-server-v1.8.1 fix: detect newly added specs in dev-server compilation (#17950) chore: Remove pkg/driver //@ts-nocheck part 3 (#19837) chore: set up semantic-pull-request GitHub Action (#20091) chore: release @cypress/react-v5.12.2 fix: remove nullish coalescing in js files to support node 12 (#20094) docs: update @cypress/webpack-preprocessor links (#19902) refactor: use aliases instead of meta (#19566)
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
const _ = require('lodash')
|
|
const EE = require('events')
|
|
const Promise = require('bluebird')
|
|
|
|
const UNDEFINED_SERIALIZED = '__cypress_undefined__'
|
|
|
|
const serializeError = (err) => {
|
|
return _.pick(err, 'name', 'message', 'stack', 'code', 'annotated', 'type', 'isCypressErr', 'messageMarkdown')
|
|
}
|
|
|
|
module.exports = {
|
|
serializeError,
|
|
|
|
nonNodeRequires () {
|
|
return Object.keys(require.cache).filter((c) => !c.includes('/node_modules/'))
|
|
},
|
|
|
|
wrapIpc (aProcess) {
|
|
const emitter = new EE()
|
|
|
|
aProcess.on('message', (message) => {
|
|
return emitter.emit(message.event, ...message.args)
|
|
})
|
|
|
|
// prevent max listeners warning on ipc
|
|
// @see https://github.com/cypress-io/cypress/issues/1305#issuecomment-780895569
|
|
emitter.setMaxListeners(Infinity)
|
|
|
|
return {
|
|
send (event, ...args) {
|
|
if (aProcess.killed) {
|
|
return
|
|
}
|
|
|
|
return aProcess.send({
|
|
event,
|
|
args,
|
|
})
|
|
},
|
|
|
|
on: emitter.on.bind(emitter),
|
|
removeListener: emitter.removeListener.bind(emitter),
|
|
}
|
|
},
|
|
|
|
wrapChildPromise (ipc, invoke, ids, args = []) {
|
|
return Promise.try(() => {
|
|
return invoke(ids.eventId, args)
|
|
})
|
|
.then((value) => {
|
|
// undefined is coerced into null when sent over ipc, but we need
|
|
// to differentiate between them for 'task' event
|
|
if (value === undefined) {
|
|
value = UNDEFINED_SERIALIZED
|
|
}
|
|
|
|
return ipc.send(`promise:fulfilled:${ids.invocationId}`, null, value)
|
|
}).catch((err) => {
|
|
return ipc.send(`promise:fulfilled:${ids.invocationId}`, serializeError(err))
|
|
})
|
|
},
|
|
}
|