Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
* Bump dev dependencies

* Bump dependencies

* Upgrade XO and reformat
  • Loading branch information
novemberborn committed Apr 26, 2021
1 parent 9a9a5d4 commit e9a69dc
Show file tree
Hide file tree
Showing 10 changed files with 571 additions and 431 deletions.
27 changes: 15 additions & 12 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class AssertionError extends Error {
// Reserved for power-assert statements
this.statements = [];

if (options.savedError) {
this.savedError = options.savedError;
} else {
this.savedError = getErrorWithLongStackTrace();
}
this.savedError = options.savedError ? options.savedError : getErrorWithLongStackTrace();
}
}
exports.AssertionError = AssertionError;
Expand Down Expand Up @@ -502,7 +498,7 @@ class Assertions {
retval = fn();
if (isPromise(retval)) {
// Here isPromise() checks if something is "promise like". Cast to an actual promise.
Promise.resolve(retval).catch(noop);
Promise.resolve(retval).catch(noop); // eslint-disable-line promise/prefer-await-to-then
fail(new AssertionError({
assertion: 'throws',
message,
Expand Down Expand Up @@ -562,7 +558,7 @@ class Assertions {
return Promise.resolve();
}

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

pending(intermediate);
// Don't reject the returned promise, even if the assertion fails.
return intermediate.catch(noop);
try {
return await intermediate;
} catch {
// Don't reject the returned promise, even if the assertion fails.
}
};

if (isPromise(thrower)) {
Expand Down Expand Up @@ -669,7 +668,7 @@ class Assertions {
return Promise.resolve();
}

const handlePromise = (promise, wasReturned) => {
const handlePromise = async (promise, wasReturned) => {
// Create an error object to record the stack before it gets lost in the promise chain.
const savedError = getErrorWithLongStackTrace();
// Handle "promise like" objects by casting to a real Promise.
Expand All @@ -682,8 +681,12 @@ class Assertions {
});
});
pending(intermediate);
// Don't reject the returned promise, even if the assertion fails.
return intermediate.catch(noop);

try {
return await intermediate;
} catch {
// Don't reject the returned promise, even if the assertion fails.
}
};

if (isPromise(nonThrower)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/plugin-support/shared-workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async function observeWorkerProcess(fork, runStatus) {
signalDeregistered = resolve;
});

fork.promise.finally(() => {
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
if (registrationCount === 0) {
signalDeregistered();
}
Expand Down Expand Up @@ -98,7 +98,7 @@ async function observeWorkerProcess(fork, runStatus) {
port
}, [port]);

fork.promise.finally(() => {
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
launched.worker.postMessage({
type: 'deregister-test-worker',
id: fork.forkId
Expand Down
4 changes: 2 additions & 2 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Test {
this.refreshTimeout();

promise
.catch(error => this.saveFirstError(error))
.catch(error => this.saveFirstError(error)) // eslint-disable-line promise/prefer-await-to-then
.then(() => { // eslint-disable-line promise/prefer-await-to-then
this.pendingAssertionCount--;
this.refreshTimeout();
Expand Down Expand Up @@ -636,7 +636,7 @@ class Test {
};

promise
.catch(error => {
.catch(error => { // eslint-disable-line promise/prefer-await-to-then
if (!this.detectImproperThrows(error)) {
this.saveFirstError(new assert.AssertionError({
message: 'Rejected promise returned by test',
Expand Down
2 changes: 1 addition & 1 deletion lib/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Watcher {
this.clearLogOnNextRun = false;
}
})
.catch(rethrowAsync);
.catch(rethrowAsync); // eslint-disable-line promise/prefer-await-to-then
};

this.testDependencies = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/worker/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ if (isRunningInThread) {
const {workerData} = require('worker_threads');
const {options} = workerData;
delete workerData.options; // Don't allow user code access.
run(options).catch(onError);
run(options).catch(onError); // eslint-disable-line promise/prefer-await-to-then
} else if (isRunningInChildProcess) {
channel.send({type: 'ready-for-options'});
channel.options.then(run).catch(onError); // eslint-disable-line promise/prefer-await-to-then
Expand Down
2 changes: 1 addition & 1 deletion lib/worker/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function registerSharedWorker(filename, initialData) {
sharedWorkerHandle.ref();
const ready = pEvent(ourPort, 'message', ({type}) => type === 'ready').then(() => { // eslint-disable-line promise/prefer-await-to-then
currentlyAvailable = error === null;
}).finally(() => {
}).finally(() => { // eslint-disable-line promise/prefer-await-to-then
// Once ready, it's up to user code to subscribe to messages, which (see
// below) causes us to reference the port.
sharedWorkerHandle.unref();
Expand Down

0 comments on commit e9a69dc

Please sign in to comment.