bun-types 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/types.d.ts +263 -14
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for bun 0.6.
|
|
1
|
+
// Type definitions for bun 0.6.6
|
|
2
2
|
// Project: https://github.com/oven-sh/bun
|
|
3
3
|
// Definitions by: Jarred Sumner <https://github.com/Jarred-Sumner>
|
|
4
4
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
@@ -3045,7 +3045,41 @@ declare module "bun:test" {
|
|
|
3045
3045
|
*/
|
|
3046
3046
|
export type Describe = {
|
|
3047
3047
|
(label: string, fn: () => void): void;
|
|
3048
|
-
|
|
3048
|
+
/**
|
|
3049
|
+
* Skips all other tests, except this group of tests.
|
|
3050
|
+
*
|
|
3051
|
+
* @param label the label for the tests
|
|
3052
|
+
* @param fn the function that defines the tests
|
|
3053
|
+
*/
|
|
3054
|
+
only(label: string, fn: () => void): void;
|
|
3055
|
+
/**
|
|
3056
|
+
* Skips this group of tests.
|
|
3057
|
+
*
|
|
3058
|
+
* @param label the label for the tests
|
|
3059
|
+
* @param fn the function that defines the tests
|
|
3060
|
+
*/
|
|
3061
|
+
skip(label: string, fn: () => void): void;
|
|
3062
|
+
/**
|
|
3063
|
+
* Marks this group of tests as to be written or to be fixed.
|
|
3064
|
+
*
|
|
3065
|
+
* @param label the label for the tests
|
|
3066
|
+
* @param fn the function that defines the tests
|
|
3067
|
+
*/
|
|
3068
|
+
todo(label: string, fn?: () => void): void;
|
|
3069
|
+
/**
|
|
3070
|
+
* Runs this group of tests, only if `condition` is true.
|
|
3071
|
+
*
|
|
3072
|
+
* This is the opposite of `describe.skipIf()`.
|
|
3073
|
+
*
|
|
3074
|
+
* @param condition if these tests should run
|
|
3075
|
+
*/
|
|
3076
|
+
if(condition: boolean): (label: string, fn: () => void) => void;
|
|
3077
|
+
/**
|
|
3078
|
+
* Skips this group of tests, if `condition` is true.
|
|
3079
|
+
*
|
|
3080
|
+
* @param condition if these tests should be skipped
|
|
3081
|
+
*/
|
|
3082
|
+
skipIf(condition: boolean): (label: string, fn: () => void) => void;
|
|
3049
3083
|
};
|
|
3050
3084
|
/**
|
|
3051
3085
|
* Describes a group of related tests.
|
|
@@ -3134,6 +3168,31 @@ declare module "bun:test" {
|
|
|
3134
3168
|
| (() => void | Promise<unknown>)
|
|
3135
3169
|
| ((done: (err?: unknown) => void) => void),
|
|
3136
3170
|
): void;
|
|
3171
|
+
export type TestOptions = {
|
|
3172
|
+
/**
|
|
3173
|
+
* Sets the timeout for the test in milliseconds.
|
|
3174
|
+
*
|
|
3175
|
+
* If the test does not complete within this time, the test will fail with:
|
|
3176
|
+
* ```ts
|
|
3177
|
+
* 'Timeout: test {name} timed out after 5000ms'
|
|
3178
|
+
* ```
|
|
3179
|
+
*
|
|
3180
|
+
* @default 5000 // 5 seconds
|
|
3181
|
+
*/
|
|
3182
|
+
timeout?: number;
|
|
3183
|
+
/**
|
|
3184
|
+
* Sets the number of times to retry the test if it fails.
|
|
3185
|
+
*
|
|
3186
|
+
* @default 0
|
|
3187
|
+
*/
|
|
3188
|
+
retry?: number;
|
|
3189
|
+
/**
|
|
3190
|
+
* Sets the number of times to repeat the test, regardless of whether it passed or failed.
|
|
3191
|
+
*
|
|
3192
|
+
* @default 0
|
|
3193
|
+
*/
|
|
3194
|
+
repeats?: number;
|
|
3195
|
+
};
|
|
3137
3196
|
/**
|
|
3138
3197
|
* Runs a test.
|
|
3139
3198
|
*
|
|
@@ -3147,8 +3206,13 @@ declare module "bun:test" {
|
|
|
3147
3206
|
* expect(response.ok).toBe(true);
|
|
3148
3207
|
* });
|
|
3149
3208
|
*
|
|
3209
|
+
* test("can set a timeout", async () => {
|
|
3210
|
+
* await Bun.sleep(100);
|
|
3211
|
+
* }, 50); // or { timeout: 50 }
|
|
3212
|
+
*
|
|
3150
3213
|
* @param label the label for the test
|
|
3151
3214
|
* @param fn the test function
|
|
3215
|
+
* @param options the test timeout or options
|
|
3152
3216
|
*/
|
|
3153
3217
|
export type Test = {
|
|
3154
3218
|
(
|
|
@@ -3157,45 +3221,44 @@ declare module "bun:test" {
|
|
|
3157
3221
|
| (() => void | Promise<unknown>)
|
|
3158
3222
|
| ((done: (err?: unknown) => void) => void),
|
|
3159
3223
|
/**
|
|
3160
|
-
*
|
|
3161
|
-
*
|
|
3162
|
-
*
|
|
3163
|
-
*
|
|
3164
|
-
*
|
|
3165
|
-
* ```
|
|
3224
|
+
* - If a `number`, sets the timeout for the test in milliseconds.
|
|
3225
|
+
* - If an `object`, sets the options for the test.
|
|
3226
|
+
* - `timeout` sets the timeout for the test in milliseconds.
|
|
3227
|
+
* - `retry` sets the number of times to retry the test if it fails.
|
|
3228
|
+
* - `repeats` sets the number of times to repeat the test, regardless of whether it passed or failed.
|
|
3166
3229
|
*/
|
|
3167
|
-
|
|
3230
|
+
options?: number | TestOptions,
|
|
3168
3231
|
): void;
|
|
3169
3232
|
/**
|
|
3170
3233
|
* Skips all other tests, except this test.
|
|
3171
|
-
* @deprecated Not yet implemented.
|
|
3172
3234
|
*
|
|
3173
3235
|
* @param label the label for the test
|
|
3174
3236
|
* @param fn the test function
|
|
3175
|
-
* @param
|
|
3237
|
+
* @param options the test timeout or options
|
|
3176
3238
|
*/
|
|
3177
3239
|
only(
|
|
3178
3240
|
label: string,
|
|
3179
3241
|
fn:
|
|
3180
3242
|
| (() => void | Promise<unknown>)
|
|
3181
3243
|
| ((done: (err?: unknown) => void) => void),
|
|
3182
|
-
|
|
3244
|
+
options?: number | TestOptions,
|
|
3183
3245
|
): void;
|
|
3184
3246
|
/**
|
|
3185
3247
|
* Skips this test.
|
|
3186
3248
|
*
|
|
3187
3249
|
* @param label the label for the test
|
|
3188
3250
|
* @param fn the test function
|
|
3251
|
+
* @param options the test timeout or options
|
|
3189
3252
|
*/
|
|
3190
3253
|
skip(
|
|
3191
3254
|
label: string,
|
|
3192
3255
|
fn:
|
|
3193
3256
|
| (() => void | Promise<unknown>)
|
|
3194
3257
|
| ((done: (err?: unknown) => void) => void),
|
|
3195
|
-
|
|
3258
|
+
options?: number | TestOptions,
|
|
3196
3259
|
): void;
|
|
3197
3260
|
/**
|
|
3198
|
-
*
|
|
3261
|
+
* Marks this test as to be written or to be fixed.
|
|
3199
3262
|
*
|
|
3200
3263
|
* When a test function is passed, it will be marked as `todo` in the test results
|
|
3201
3264
|
* as long the test does not pass. When the test passes, the test will be marked as
|
|
@@ -3204,13 +3267,45 @@ declare module "bun:test" {
|
|
|
3204
3267
|
*
|
|
3205
3268
|
* @param label the label for the test
|
|
3206
3269
|
* @param fn the test function
|
|
3270
|
+
* @param options the test timeout or options
|
|
3207
3271
|
*/
|
|
3208
3272
|
todo(
|
|
3209
3273
|
label: string,
|
|
3210
3274
|
fn?:
|
|
3211
3275
|
| (() => void | Promise<unknown>)
|
|
3212
3276
|
| ((done: (err?: unknown) => void) => void),
|
|
3277
|
+
options?: number | TestOptions,
|
|
3213
3278
|
): void;
|
|
3279
|
+
/**
|
|
3280
|
+
* Runs this test, if `condition` is true.
|
|
3281
|
+
*
|
|
3282
|
+
* This is the opposite of `test.skipIf()`.
|
|
3283
|
+
*
|
|
3284
|
+
* @param condition if the test should run
|
|
3285
|
+
*/
|
|
3286
|
+
if(
|
|
3287
|
+
condition: boolean,
|
|
3288
|
+
): (
|
|
3289
|
+
label: string,
|
|
3290
|
+
fn:
|
|
3291
|
+
| (() => void | Promise<unknown>)
|
|
3292
|
+
| ((done: (err?: unknown) => void) => void),
|
|
3293
|
+
options?: number | TestOptions,
|
|
3294
|
+
) => void;
|
|
3295
|
+
/**
|
|
3296
|
+
* Skips this test, if `condition` is true.
|
|
3297
|
+
*
|
|
3298
|
+
* @param condition if the test should be skipped
|
|
3299
|
+
*/
|
|
3300
|
+
skipIf(
|
|
3301
|
+
condition: boolean,
|
|
3302
|
+
): (
|
|
3303
|
+
label: string,
|
|
3304
|
+
fn:
|
|
3305
|
+
| (() => void | Promise<unknown>)
|
|
3306
|
+
| ((done: (err?: unknown) => void) => void),
|
|
3307
|
+
options?: number | TestOptions,
|
|
3308
|
+
) => void;
|
|
3214
3309
|
};
|
|
3215
3310
|
/**
|
|
3216
3311
|
* Runs a test.
|
|
@@ -3545,6 +3640,160 @@ declare module "bun:test" {
|
|
|
3545
3640
|
* expect(new Set()).toBeEmpty();
|
|
3546
3641
|
*/
|
|
3547
3642
|
toBeEmpty(): void;
|
|
3643
|
+
/**
|
|
3644
|
+
* Asserts that a value is `null` or `undefined`.
|
|
3645
|
+
*
|
|
3646
|
+
* @example
|
|
3647
|
+
* expect(null).toBeNil();
|
|
3648
|
+
* expect(undefined).toBeNil();
|
|
3649
|
+
*/
|
|
3650
|
+
toBeNil(): void;
|
|
3651
|
+
/**
|
|
3652
|
+
* Asserts that a value is a `boolean`.
|
|
3653
|
+
*
|
|
3654
|
+
* @example
|
|
3655
|
+
* expect(true).toBeBoolean();
|
|
3656
|
+
* expect(false).toBeBoolean();
|
|
3657
|
+
* expect(null).not.toBeBoolean();
|
|
3658
|
+
* expect(0).not.toBeBoolean();
|
|
3659
|
+
*/
|
|
3660
|
+
toBeBoolean(): void;
|
|
3661
|
+
/**
|
|
3662
|
+
* Asserts that a value is `true`.
|
|
3663
|
+
*
|
|
3664
|
+
* @example
|
|
3665
|
+
* expect(true).toBeTrue();
|
|
3666
|
+
* expect(false).not.toBeTrue();
|
|
3667
|
+
* expect(1).not.toBeTrue();
|
|
3668
|
+
*/
|
|
3669
|
+
toBeTrue(): void;
|
|
3670
|
+
/**
|
|
3671
|
+
* Asserts that a value is `false`.
|
|
3672
|
+
*
|
|
3673
|
+
* @example
|
|
3674
|
+
* expect(false).toBeFalse();
|
|
3675
|
+
* expect(true).not.toBeFalse();
|
|
3676
|
+
* expect(0).not.toBeFalse();
|
|
3677
|
+
*/
|
|
3678
|
+
toBeFalse(): void;
|
|
3679
|
+
/**
|
|
3680
|
+
* Asserts that a value is a `number`.
|
|
3681
|
+
*
|
|
3682
|
+
* @example
|
|
3683
|
+
* expect(1).toBeNumber();
|
|
3684
|
+
* expect(3.14).toBeNumber();
|
|
3685
|
+
* expect(NaN).toBeNumber();
|
|
3686
|
+
* expect(BigInt(1)).not.toBeNumber();
|
|
3687
|
+
*/
|
|
3688
|
+
toBeNumber(): void;
|
|
3689
|
+
/**
|
|
3690
|
+
* Asserts that a value is a `number`, and is an integer.
|
|
3691
|
+
*
|
|
3692
|
+
* @example
|
|
3693
|
+
* expect(1).toBeInteger();
|
|
3694
|
+
* expect(3.14).not.toBeInteger();
|
|
3695
|
+
* expect(NaN).not.toBeInteger();
|
|
3696
|
+
*/
|
|
3697
|
+
toBeInteger(): void;
|
|
3698
|
+
/**
|
|
3699
|
+
* Asserts that a value is a `number`, and is not `NaN` or `Infinity`.
|
|
3700
|
+
*
|
|
3701
|
+
* @example
|
|
3702
|
+
* expect(1).toBeFinite();
|
|
3703
|
+
* expect(3.14).toBeFinite();
|
|
3704
|
+
* expect(NaN).not.toBeFinite();
|
|
3705
|
+
* expect(Infinity).not.toBeFinite();
|
|
3706
|
+
*/
|
|
3707
|
+
toBeFinite(): void;
|
|
3708
|
+
/**
|
|
3709
|
+
* Asserts that a value is a positive `number`.
|
|
3710
|
+
*
|
|
3711
|
+
* @example
|
|
3712
|
+
* expect(1).toBePositive();
|
|
3713
|
+
* expect(-3.14).not.toBePositive();
|
|
3714
|
+
* expect(NaN).not.toBePositive();
|
|
3715
|
+
*/
|
|
3716
|
+
toBePositive(): void;
|
|
3717
|
+
/**
|
|
3718
|
+
* Asserts that a value is a negative `number`.
|
|
3719
|
+
*
|
|
3720
|
+
* @example
|
|
3721
|
+
* expect(-3.14).toBeNegative();
|
|
3722
|
+
* expect(1).not.toBeNegative();
|
|
3723
|
+
* expect(NaN).not.toBeNegative();
|
|
3724
|
+
*/
|
|
3725
|
+
toBeNegative(): void;
|
|
3726
|
+
/**
|
|
3727
|
+
* Asserts that a value is a number between a start and end value.
|
|
3728
|
+
*
|
|
3729
|
+
* @param start the start number (inclusive)
|
|
3730
|
+
* @param end the end number (exclusive)
|
|
3731
|
+
*/
|
|
3732
|
+
toBeWithin(start: number, end: number): void;
|
|
3733
|
+
/**
|
|
3734
|
+
* Asserts that a value is a `symbol`.
|
|
3735
|
+
*
|
|
3736
|
+
* @example
|
|
3737
|
+
* expect(Symbol("foo")).toBeSymbol();
|
|
3738
|
+
* expect("foo").not.toBeSymbol();
|
|
3739
|
+
*/
|
|
3740
|
+
toBeSymbol(): void;
|
|
3741
|
+
/**
|
|
3742
|
+
* Asserts that a value is a `function`.
|
|
3743
|
+
*
|
|
3744
|
+
* @example
|
|
3745
|
+
* expect(() => {}).toBeFunction();
|
|
3746
|
+
*/
|
|
3747
|
+
toBeFunction(): void;
|
|
3748
|
+
/**
|
|
3749
|
+
* Asserts that a value is a `Date` object.
|
|
3750
|
+
*
|
|
3751
|
+
* To check if a date is valid, use `toBeValidDate()` instead.
|
|
3752
|
+
*
|
|
3753
|
+
* @example
|
|
3754
|
+
* expect(new Date()).toBeDate();
|
|
3755
|
+
* expect(new Date(null)).toBeDate();
|
|
3756
|
+
* expect("2020-03-01").not.toBeDate();
|
|
3757
|
+
*/
|
|
3758
|
+
toBeDate(): void;
|
|
3759
|
+
/**
|
|
3760
|
+
* Asserts that a value is a valid `Date` object.
|
|
3761
|
+
*
|
|
3762
|
+
* @example
|
|
3763
|
+
* expect(new Date()).toBeValidDate();
|
|
3764
|
+
* expect(new Date(null)).not.toBeValidDate();
|
|
3765
|
+
* expect("2020-03-01").not.toBeValidDate();
|
|
3766
|
+
*/
|
|
3767
|
+
toBeValidDate(): void;
|
|
3768
|
+
/**
|
|
3769
|
+
* Asserts that a value is a `string`.
|
|
3770
|
+
*
|
|
3771
|
+
* @example
|
|
3772
|
+
* expect("foo").toBeString();
|
|
3773
|
+
* expect(new String("bar")).toBeString();
|
|
3774
|
+
* expect(123).not.toBeString();
|
|
3775
|
+
*/
|
|
3776
|
+
toBeString(): void;
|
|
3777
|
+
/**
|
|
3778
|
+
* Asserts that a value includes a `string`.
|
|
3779
|
+
*
|
|
3780
|
+
* For non-string values, use `toContain()` instead.
|
|
3781
|
+
*
|
|
3782
|
+
* @param expected the expected substring
|
|
3783
|
+
*/
|
|
3784
|
+
toInclude(expected: string): void;
|
|
3785
|
+
/**
|
|
3786
|
+
* Asserts that a value starts with a `string`.
|
|
3787
|
+
*
|
|
3788
|
+
* @param expected the string to start with
|
|
3789
|
+
*/
|
|
3790
|
+
toStartWith(expected: string): void;
|
|
3791
|
+
/**
|
|
3792
|
+
* Asserts that a value ends with a `string`.
|
|
3793
|
+
*
|
|
3794
|
+
* @param expected the string to end with
|
|
3795
|
+
*/
|
|
3796
|
+
toEndWith(expected: string): void;
|
|
3548
3797
|
};
|
|
3549
3798
|
}
|
|
3550
3799
|
|