Skip to content

Commit e9a69dc

Browse files
authored
Update dependencies
* Bump dev dependencies * Bump dependencies * Upgrade XO and reformat
1 parent 9a9a5d4 commit e9a69dc

File tree

10 files changed

+571
-431
lines changed

10 files changed

+571
-431
lines changed

lib/assert.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ class AssertionError extends Error {
5555
// Reserved for power-assert statements
5656
this.statements = [];
5757

58-
if (options.savedError) {
59-
this.savedError = options.savedError;
60-
} else {
61-
this.savedError = getErrorWithLongStackTrace();
62-
}
58+
this.savedError = options.savedError ? options.savedError : getErrorWithLongStackTrace();
6359
}
6460
}
6561
exports.AssertionError = AssertionError;
@@ -502,7 +498,7 @@ class Assertions {
502498
retval = fn();
503499
if (isPromise(retval)) {
504500
// Here isPromise() checks if something is "promise like". Cast to an actual promise.
505-
Promise.resolve(retval).catch(noop);
501+
Promise.resolve(retval).catch(noop); // eslint-disable-line promise/prefer-await-to-then
506502
fail(new AssertionError({
507503
assertion: 'throws',
508504
message,
@@ -562,7 +558,7 @@ class Assertions {
562558
return Promise.resolve();
563559
}
564560

565-
const handlePromise = (promise, wasReturned) => {
561+
const handlePromise = async (promise, wasReturned) => {
566562
// Create an error object to record the stack before it gets lost in the promise chain.
567563
const savedError = getErrorWithLongStackTrace();
568564
// Handle "promise like" objects by casting to a real Promise.
@@ -586,8 +582,11 @@ class Assertions {
586582
});
587583

588584
pending(intermediate);
589-
// Don't reject the returned promise, even if the assertion fails.
590-
return intermediate.catch(noop);
585+
try {
586+
return await intermediate;
587+
} catch {
588+
// Don't reject the returned promise, even if the assertion fails.
589+
}
591590
};
592591

593592
if (isPromise(thrower)) {
@@ -669,7 +668,7 @@ class Assertions {
669668
return Promise.resolve();
670669
}
671670

672-
const handlePromise = (promise, wasReturned) => {
671+
const handlePromise = async (promise, wasReturned) => {
673672
// Create an error object to record the stack before it gets lost in the promise chain.
674673
const savedError = getErrorWithLongStackTrace();
675674
// Handle "promise like" objects by casting to a real Promise.
@@ -682,8 +681,12 @@ class Assertions {
682681
});
683682
});
684683
pending(intermediate);
685-
// Don't reject the returned promise, even if the assertion fails.
686-
return intermediate.catch(noop);
684+
685+
try {
686+
return await intermediate;
687+
} catch {
688+
// Don't reject the returned promise, even if the assertion fails.
689+
}
687690
};
688691

689692
if (isPromise(nonThrower)) {

lib/plugin-support/shared-workers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async function observeWorkerProcess(fork, runStatus) {
5757
signalDeregistered = resolve;
5858
});
5959

60-
fork.promise.finally(() => {
60+
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
6161
if (registrationCount === 0) {
6262
signalDeregistered();
6363
}
@@ -98,7 +98,7 @@ async function observeWorkerProcess(fork, runStatus) {
9898
port
9999
}, [port]);
100100

101-
fork.promise.finally(() => {
101+
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
102102
launched.worker.postMessage({
103103
type: 'deregister-test-worker',
104104
id: fork.forkId

lib/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class Test {
333333
this.refreshTimeout();
334334

335335
promise
336-
.catch(error => this.saveFirstError(error))
336+
.catch(error => this.saveFirstError(error)) // eslint-disable-line promise/prefer-await-to-then
337337
.then(() => { // eslint-disable-line promise/prefer-await-to-then
338338
this.pendingAssertionCount--;
339339
this.refreshTimeout();
@@ -636,7 +636,7 @@ class Test {
636636
};
637637

638638
promise
639-
.catch(error => {
639+
.catch(error => { // eslint-disable-line promise/prefer-await-to-then
640640
if (!this.detectImproperThrows(error)) {
641641
this.saveFirstError(new assert.AssertionError({
642642
message: 'Rejected promise returned by test',

lib/watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class Watcher {
144144
this.clearLogOnNextRun = false;
145145
}
146146
})
147-
.catch(rethrowAsync);
147+
.catch(rethrowAsync); // eslint-disable-line promise/prefer-await-to-then
148148
};
149149

150150
this.testDependencies = [];

lib/worker/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ if (isRunningInThread) {
252252
const {workerData} = require('worker_threads');
253253
const {options} = workerData;
254254
delete workerData.options; // Don't allow user code access.
255-
run(options).catch(onError);
255+
run(options).catch(onError); // eslint-disable-line promise/prefer-await-to-then
256256
} else if (isRunningInChildProcess) {
257257
channel.send({type: 'ready-for-options'});
258258
channel.options.then(run).catch(onError); // eslint-disable-line promise/prefer-await-to-then

lib/worker/channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function registerSharedWorker(filename, initialData) {
172172
sharedWorkerHandle.ref();
173173
const ready = pEvent(ourPort, 'message', ({type}) => type === 'ready').then(() => { // eslint-disable-line promise/prefer-await-to-then
174174
currentlyAvailable = error === null;
175-
}).finally(() => {
175+
}).finally(() => { // eslint-disable-line promise/prefer-await-to-then
176176
// Once ready, it's up to user code to subscribe to messages, which (see
177177
// below) causes us to reference the port.
178178
sharedWorkerHandle.unref();

0 commit comments

Comments
 (0)