Skip to content

Commit

Permalink
Abort signal immediately to fix race condition of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Aug 12, 2023
1 parent ad57f7c commit 4d8e68e
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions packages/api/test/unit/client/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,7 @@ describe("FetchError", function () {
);
}

let signal: AbortSignal | undefined;
if (abort) {
const controller = new AbortController();
setTimeout(() => controller.abort(), 0);
signal = controller.signal;
} else if (timeout) {
signal = AbortSignal.timeout(10);
}
const signal = abort ? AbortSignal.abort() : timeout ? AbortSignal.timeout(1) : null;
await expect(fetch(url, {signal})).to.be.rejected.then((error: FetchError) => {
expect(error.type).to.be.equal(testCase.errorType);
expect(error.code).to.be.equal(testCase.errorCode);
Expand Down

0 comments on commit 4d8e68e

Please sign in to comment.