generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump dependencies / ESM / bundle with esbuild (#36)
* Support arm64 architecture * Bump references to v1 rc * Bump dependencies / ESM / bundle with esbuild
- Loading branch information
Showing
18 changed files
with
3,448 additions
and
19,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {jest} from '@jest/globals' | ||
import {FunctionLike} from 'jest-mock' | ||
|
||
export type SpiedModule<T extends object> = { | ||
[K in keyof T]: T[K] extends FunctionLike | ||
? jest.SpiedFunction<T[K]> & T[K] | ||
: T[K] | ||
} | ||
|
||
export const spyOnModule = async <T extends object>( | ||
moduleName: string | ||
): Promise<SpiedModule<T>> => { | ||
const actual = await import(moduleName) | ||
const props = Object.getOwnPropertyNames(actual) | ||
jest.unstable_mockModule(moduleName, () => | ||
Object.fromEntries( | ||
props.map(key => { | ||
let value = actual[key] | ||
if (typeof value === 'function') { | ||
value = jest.fn(value) | ||
} | ||
return [key, value] | ||
}) | ||
) | ||
) | ||
return await import(moduleName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.