Skip to content

Commit

Permalink
refactor: remove uncaught:exception event
Browse files Browse the repository at this point in the history
The event has been removed in favor of listening the "uncaughtException"
event
  • Loading branch information
thetutlage committed Jun 24, 2023
1 parent da7757f commit 1c50571
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 32 deletions.
20 changes: 0 additions & 20 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export class Runner<Context extends Record<any, any>> extends Macroable {
*/
#tracker?: Tracker

/**
* Handler to listen for uncaughtException
*/
#uncaughtExceptionHandler?: NodeJS.UncaughtExceptionListener

/**
* A collection of suites
*/
Expand Down Expand Up @@ -81,9 +76,6 @@ export class Runner<Context extends Record<any, any>> extends Macroable {
#boot() {
this.#tracker = new Tracker()

this.#emitter.on('uncaught:exception', (payload) =>
this.#tracker?.processEvent('uncaught:exception', payload)
)
this.#emitter.on('runner:start', (payload) =>
this.#tracker?.processEvent('runner:start', payload)
)
Expand Down Expand Up @@ -126,18 +118,6 @@ export class Runner<Context extends Record<any, any>> extends Macroable {
return this
}

/**
* Manage unhandled exceptions occurred during tests
*/
manageUnHandledExceptions(): this {
if (!this.#uncaughtExceptionHandler) {
this.#uncaughtExceptionHandler = (error) => this.#emitter.emit('uncaught:exception', error)
process.on('uncaughtException', this.#uncaughtExceptionHandler)
}

return this
}

/**
* Get tests summary
*/
Expand Down
11 changes: 0 additions & 11 deletions src/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ export class Tracker {
this.#failedTestsTitles.push(payload.title.original)
}

/**
* Increment the count of uncaught exceptions
*/
#onUncaughtException() {
this.#aggregates.uncaughtExceptions++
this.#hasError = true
}

/**
* Process the tests events
*/
Expand All @@ -250,9 +242,6 @@ export class Tracker {
payload: RunnerEvents[Event]
) {
switch (event) {
case 'uncaught:exception':
this.#onUncaughtException()
break
case 'suite:start':
this.#onSuiteStart(payload as SuiteStartNode)
break
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export interface RunnerEvents {
'suite:end': SuiteEndNode
'runner:start': RunnerStartNode
'runner:end': RunnerEndNode
'uncaught:exception': Error
}

/**
Expand Down

0 comments on commit 1c50571

Please sign in to comment.