1
0
mirror of https://github.com/actions/labeler synced 2026-05-12 09:21:12 +02:00
This commit is contained in:
David Kale
2020-09-08 13:25:36 -04:00
parent e4246d2b5b
commit 91fcbb0108
4227 changed files with 416837 additions and 457884 deletions

View File

@@ -15,12 +15,10 @@ declare type JestMockFn = typeof jestMock.fn;
declare type JestMockSpyOn = typeof jestMock.spyOn;
export declare type EnvironmentContext = Partial<{
console: Console;
docblockPragmas: {
[key: string]: string | Array<string>;
};
docblockPragmas: Record<string, string | Array<string>>;
testPath: Config.Path;
}>;
declare type ModuleWrapper = (...args: Array<unknown>) => unknown;
export declare type ModuleWrapper = (module: Module, exports: Module['exports'], require: Module['require'], __dirname: string, __filename: Module['filename'], global: Global.Global, jest: Jest, ...extraGlobals: Array<Global.Global[keyof Global.Global]>) => unknown;
export declare class JestEnvironment {
constructor(config: Config.ProjectConfig, context?: EnvironmentContext);
global: Global.Global;
@@ -33,7 +31,7 @@ export declare class JestEnvironment {
teardown(): Promise<void>;
handleTestEvent?(event: Circus.Event, state: Circus.State): void;
}
export declare type Module = typeof module;
export declare type Module = NodeModule;
export interface LocalModuleRequire extends NodeRequire {
requireActual(moduleName: string): unknown;
requireMock(moduleName: string): unknown;
@@ -45,6 +43,11 @@ export interface Jest {
* @deprecated Use `expect.extend` instead
*/
addMatchers(matchers: Record<string, any>): void;
/**
* Advances all timers by the needed milliseconds so that only the next timeouts/intervals will run.
* Optionally, you can provide steps, so it will run steps amount of next timeouts/intervals.
*/
advanceTimersToNextTimer(steps?: number): void;
/**
* Disables automatic mocking in the module loader.
*/
@@ -118,6 +121,23 @@ export interface Jest {
/**
* Returns the actual module instead of a mock, bypassing all checks on
* whether the module should receive a mock implementation or not.
*
* @example
```
jest.mock('../myModule', () => {
// Require the original module to not be mocked...
const originalModule = jest.requireActual(moduleName);
return {
__esModule: true, // Use it when dealing with esModules
...originalModule,
getRandom: jest.fn().mockReturnValue(10),
};
});
const getRandom = require('../myModule').getRandom;
getRandom(); // Always returns 10
```
*/
requireActual: (moduleName: string) => unknown;
/**