aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/harness.ts
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-03-22 15:01:01 -0700
committerGravatar GitHub <noreply@github.com> 2023-03-22 15:01:01 -0700
commita5f92224b586289fc72f0abdb68b08eef9f017db (patch)
tree6092397858776820b431b0dffa635d8bc3b3185e /test/js/node/harness.ts
parent2bdaa81b1c2325687c5115b4e97627533cb3646b (diff)
downloadbun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.gz
bun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.zst
bun-a5f92224b586289fc72f0abdb68b08eef9f017db.zip
Fix types (#2453)
* WIP * WIP * WIP * WIP * Improve typechecking in type files * Fix typechecking * Update * Update submodule * CI for typechecking * Add ci * Update commands * Format after build * Dont use bunx * Rename job * Use nodemodules prettier * Update workflow * Use symlink * Debug * Debug * Clean up and rename jobs
Diffstat (limited to 'test/js/node/harness.ts')
-rw-r--r--test/js/node/harness.ts24
1 files changed, 18 insertions, 6 deletions
diff --git a/test/js/node/harness.ts b/test/js/node/harness.ts
index 9e847c649..9cea1b781 100644
--- a/test/js/node/harness.ts
+++ b/test/js/node/harness.ts
@@ -1,3 +1,4 @@
+import { AnyFunction } from "bun";
import { gcTick, hideFromStackTrace } from "harness";
import assertNode from "node:assert";
@@ -44,10 +45,20 @@ export function createTest(path: string) {
expect(true).toBe(true);
};
+ interface NodeAssert {
+ (args: any): void;
+ strictEqual: typeof strictEqual;
+ deepStrictEqual: typeof deepStrictEqual;
+ notStrictEqual: typeof notStrictEqual;
+ throws: typeof throws;
+ ok: typeof ok;
+ ifError: typeof ifError;
+ match: typeof match;
+ }
const assert = function (...args: any[]) {
// @ts-ignore
assertNode(...args);
- };
+ } as NodeAssert;
hideFromStackTrace(strictEqual);
hideFromStackTrace(notStrictEqual);
@@ -87,8 +98,8 @@ export function createTest(path: string) {
// });
// TODO: Implement this to be exact only
- function mustCall(fn?: (...args) => any, exact?: number) {
- return mustCallAtLeast(fn, exact);
+ function mustCall(fn?: (...args: any[]) => any, exact?: number) {
+ return mustCallAtLeast(fn!, exact!);
}
function closeTimers() {
@@ -114,11 +125,12 @@ export function createTest(path: string) {
}, exact);
}
- function mustCallAtLeast(fn, minimum) {
+ function mustCallAtLeast(fn: AnyFunction, minimum: number) {
return _mustCallInner(fn, minimum, "minimum");
}
- function _mustCallInner(fn, criteria = 1, field) {
+ function _mustCallInner(fn: AnyFunction, criteria = 1, field: string) {
+ // @ts-ignore
if (process._exiting) throw new Error("Cannot use common.mustCall*() in process exit handler");
if (typeof fn === "number") {
criteria = fn;
@@ -134,7 +146,7 @@ export function createTest(path: string) {
// mustCallChecks.push(context);
const done = createDone();
- const _return = (...args) => {
+ const _return = (...args: any[]) => {
try {
// @ts-ignore
const result = fn(...args);