mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-27 02:14:36 -05:00
rename clone -> cloneErr
This commit is contained in:
@@ -1285,7 +1285,7 @@ interface GenericError extends Error {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export const cloneError = function (err: CypressError | GenericError, options: {html?: boolean} = {}) {
|
||||
export const cloneErr = function (err: CypressError | GenericError, options: {html?: boolean} = {}) {
|
||||
_.defaults(options, {
|
||||
html: false,
|
||||
})
|
||||
@@ -1317,7 +1317,6 @@ export const cloneError = function (err: CypressError | GenericError, options: {
|
||||
|
||||
export {
|
||||
stripAnsi,
|
||||
cloneError as clone,
|
||||
getError as get,
|
||||
logWarning as warning,
|
||||
}
|
||||
|
||||
@@ -104,14 +104,14 @@ describe('lib/errors', () => {
|
||||
context('.clone', () => {
|
||||
it('converts err.message from ansi to html with span classes when html true', () => {
|
||||
const err = new Error(`foo${chalk.blue('bar')}${chalk.yellow('baz')}`)
|
||||
const obj = errors.clone(err, { html: true })
|
||||
const obj = errors.cloneErr(err, { html: true })
|
||||
|
||||
expect(obj.message).to.eq('foo<span class="ansi-blue-fg">bar</span><span class="ansi-yellow-fg">baz</span>')
|
||||
})
|
||||
|
||||
it('does not convert err.message from ansi to html when no html option', () => {
|
||||
const err = new Error(`foo${chalk.blue('bar')}${chalk.yellow('baz')}`)
|
||||
const obj = errors.clone(err)
|
||||
const obj = errors.cloneErr(err)
|
||||
|
||||
expect(obj.message).to.eq('foo\u001b[34mbar\u001b[39m\u001b[33mbaz\u001b[39m')
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ import Debug from 'debug'
|
||||
import type { ErrorMiddleware } from '@packages/proxy'
|
||||
import type { CyHttpMessages } from '../../types'
|
||||
import _ from 'lodash'
|
||||
import errors from '@packages/server/lib/errors'
|
||||
import * as errors from '@packages/server/lib/errors'
|
||||
|
||||
const debug = Debug('cypress:net-stubbing:server:intercept-error')
|
||||
|
||||
@@ -22,7 +22,7 @@ export const InterceptError: ErrorMiddleware = async function () {
|
||||
await request.handleSubscriptions<CyHttpMessages.NetworkError>({
|
||||
eventName: 'network:error',
|
||||
data: {
|
||||
error: errors.clone(this.error),
|
||||
error: errors.cloneErr(this.error),
|
||||
},
|
||||
mergeChanges: _.noop,
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import debugModule from 'debug'
|
||||
import * as errors from '@packages/server/lib/errors'
|
||||
|
||||
import type { HttpMiddleware } from '.'
|
||||
import type { Readable } from 'stream'
|
||||
import { InterceptError } from '@packages/net-stubbing'
|
||||
import type { Request } from '@cypress/request'
|
||||
import errors from '@packages/server/lib/errors'
|
||||
|
||||
const debug = debugModule('cypress:proxy:http:error-middleware')
|
||||
|
||||
export type ErrorMiddleware = HttpMiddleware<{
|
||||
@@ -27,7 +27,7 @@ const SendToDriver: ErrorMiddleware = function () {
|
||||
if (this.req.browserPreRequest) {
|
||||
this.socket.toDriver('request:event', 'request:error', {
|
||||
requestId: this.req.browserPreRequest.requestId,
|
||||
error: errors.clone(this.error),
|
||||
error: errors.cloneErr(this.error),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -24,3 +24,5 @@ export const log = errors.log
|
||||
export const warning = errors.warning
|
||||
|
||||
export const throwErr = errors.throwErr
|
||||
|
||||
export const cloneErr = errors.cloneErr
|
||||
|
||||
@@ -74,13 +74,13 @@ const handleEvent = function (options, bus, event, id, type, arg) {
|
||||
// }
|
||||
|
||||
// const onError = (err) => {
|
||||
// return bus.emit('project:error', errors.clone(err, { html: true }))
|
||||
// return bus.emit('project:error', errors.cloneErr(err, { html: true }))
|
||||
// }
|
||||
|
||||
// const onWarning = function (warning) {
|
||||
// warning.message = stripAnsi(warning.message)
|
||||
|
||||
// return bus.emit('project:warning', errors.clone(warning, { html: true }))
|
||||
// return bus.emit('project:warning', errors.cloneErr(warning, { html: true }))
|
||||
// }
|
||||
|
||||
// return browsers.getAllBrowsersWith(options.browser)
|
||||
|
||||
@@ -274,7 +274,7 @@ export class SocketBase {
|
||||
.then((resp) => {
|
||||
return cb({ response: resp })
|
||||
}).catch((err) => {
|
||||
return cb({ error: errors.clone(err) })
|
||||
return cb({ error: errors.cloneErr(err) })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -459,7 +459,7 @@ export class SocketBase {
|
||||
.then((resp) => {
|
||||
return cb({ response: resp })
|
||||
}).catch((err) => {
|
||||
return cb({ error: errors.clone(err) })
|
||||
return cb({ error: errors.cloneErr(err) })
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('lib/gui/events', () => {
|
||||
expect(this.send).to.be.calledWith('response', { id, data })
|
||||
},
|
||||
sendErrCalledWith: (err) => {
|
||||
expect(this.send).to.be.calledWith('response', { id, __error: errors.clone(err, { html: true }) })
|
||||
expect(this.send).to.be.calledWith('response', { id, __error: errors.cloneErr(err, { html: true }) })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ describe('lib/socket', () => {
|
||||
sinon.stub(this.options, 'onRequest').rejects(err)
|
||||
|
||||
return this.client.emit('backend:request', 'http:request', 'foo', (resp) => {
|
||||
expect(resp.error).to.deep.eq(errors.clone(err))
|
||||
expect(resp.error).to.deep.eq(errors.cloneErr(err))
|
||||
|
||||
return done()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user