-
Notifications
You must be signed in to change notification settings - Fork 715
Bun fix the unit tests 4 #9379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Bun fix the unit tests 4 #9379
Changes from all commits
1c0b32d
fa956aa
7325f79
abb43cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [test] | ||
| root = "./test" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,7 +18,9 @@ | |||||||||||||||||
| * @module common/paginator | ||||||||||||||||||
| */ | ||||||||||||||||||
|
|
||||||||||||||||||
| import * as extend from 'extend'; | ||||||||||||||||||
| import * as extendMod from 'extend'; | ||||||||||||||||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||||||||||||||||||
| const extend: typeof extendMod = (extendMod as any).default || extendMod; | ||||||||||||||||||
| import {TransformOptions} from 'stream'; | ||||||||||||||||||
| import {ResourceStream} from './resource-stream'; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -236,7 +238,7 @@ export class Paginator { | |||||||||||||||||
| if (!callback) { | ||||||||||||||||||
| return promise.then(results => [results, query, ...otherArgs]); | ||||||||||||||||||
| } | ||||||||||||||||||
| promise.then( | ||||||||||||||||||
| return promise.then( | ||||||||||||||||||
| results => callback(null, results, query, ...otherArgs), | ||||||||||||||||||
| (err: Error) => callback(err), | ||||||||||||||||||
| ); | ||||||||||||||||||
|
Comment on lines
+241
to
244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning the promise when a callback is provided can lead to unhandled promise rejections if the callback throws an error. Since callers using callbacks do not typically catch returned promises, any synchronous error thrown inside the callback will reject the returned promise and go unhandled. Use the
Suggested change
References
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| /* eslint-disable @typescript-eslint/no-explicit-any, import/no-extraneous-dependencies, n/no-extraneous-import */ | ||
| import {jest} from '@jest/globals'; | ||
|
|
||
| export const describe = (globalThis as any).describe; | ||
| export const it = (globalThis as any).it; | ||
| export const test = (globalThis as any).test; | ||
| export const expect = (globalThis as any).expect; | ||
| export const beforeEach = (globalThis as any).beforeEach; | ||
| export const afterEach = (globalThis as any).afterEach; | ||
| export const beforeAll = (globalThis as any).beforeAll; | ||
| export const afterAll = (globalThis as any).afterAll; | ||
|
|
||
| export const mock: any = Object.assign( | ||
| (...args: any[]) => (jest.fn as any)(...args), | ||
| { | ||
| module: (moduleName: string, factory: () => any) => { | ||
| jest.mock(moduleName, factory); | ||
| }, | ||
| restore: () => jest.restoreAllMocks(), | ||
| }, | ||
| ); | ||
|
|
||
| export const spyOn: any = (obj: any, method: any) => jest.spyOn(obj, method); | ||
| export type Mock = any; | ||
| export {jest}; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| declare module 'bun:test' { | ||
| export type DoneCallback = (err?: any) => void; | ||
| export function describe(name: string, fn: () => void): void; | ||
| export namespace describe { | ||
| export function only(name: string, fn: () => void): void; | ||
| export function skip(name: string, fn: () => void): void; | ||
| } | ||
| export function it(name: string, fn: (done: DoneCallback) => any): void; | ||
| export namespace it { | ||
| export function only(name: string, fn: (done: DoneCallback) => any): void; | ||
| export function skip(name: string, fn: (done: DoneCallback) => any): void; | ||
| } | ||
| export function test(name: string, fn: (done: DoneCallback) => any): void; | ||
| export namespace test { | ||
| export function only(name: string, fn: (done: DoneCallback) => any): void; | ||
| export function skip(name: string, fn: (done: DoneCallback) => any): void; | ||
| } | ||
| export function beforeEach(fn: (done: DoneCallback) => any): void; | ||
| export function afterEach(fn: (done: DoneCallback) => any): void; | ||
| export function beforeAll(fn: (done: DoneCallback) => any): void; | ||
| export function afterAll(fn: (done: DoneCallback) => any): void; | ||
| export const expect: any; | ||
| export function mock<T extends (...args: any[]) => any = (...args: any[]) => any>( | ||
| fn?: T | ||
| ): Mock<T>; | ||
| export namespace mock { | ||
| export function module(moduleName: string, factory: () => any): void; | ||
| export function restore(): void; | ||
| } | ||
| export function spyOn(obj: any, method: any): Mock<any>; | ||
| export const jest: any; | ||
| export interface Mock< | ||
| T extends (...args: any[]) => any = (...args: any[]) => any, | ||
| > { | ||
| (...args: Parameters<T>): ReturnType<T>; | ||
| mock: { | ||
| calls: any[]; | ||
| results: {type: string; value: any}[]; | ||
| lastCall?: any; | ||
| }; | ||
| mockImplementation( | ||
| fn?: (a?: any, b?: any, c?: any, d?: any, ...args: any[]) => any | ||
| ): this; | ||
| mockReturnValue(val: any): this; | ||
| mockResolvedValue(val: any): this; | ||
| mockRejectedValue(val: any): this; | ||
| mockRestore(): void; | ||
| mockClear(): void; | ||
| mockReset(): void; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing the
lintandunitstest checks above the core package skip check bypasses the skip logic for those test types in non-core triggers. This will cause core packages to run unit and lint tests unnecessarily during non-core trigger builds, wasting CI resources. Keep the core package skip check at the top of the conditional block.