Commit e11c97e9 authored by KangMin An's avatar KangMin An
Browse files

Delete: Untracked Files-nodemodules & package.json

parent 9d3019a3
{
"name": "@jest/types",
"version": "26.6.2",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-types"
},
"engines": {
"node": ">= 10.14.2"
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^15.0.0",
"chalk": "^4.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4c46930615602cbf983fb7e8e82884c282a624d5"
}
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/istanbul-lib-coverage`
# Summary
This package contains type definitions for istanbul-lib-coverage (https://istanbul.js.org).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-coverage.
### Additional Details
* Last updated: Tue, 09 Jun 2020 16:25:43 GMT
* Dependencies: none
* Global values: none
# Credits
These definitions were written by [Jason Cheatham](https://github.com/jason0x43), and [Lorenzo Rapetti](https://github.com/loryman).
// Type definitions for istanbul-lib-coverage 2.0
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
// Lorenzo Rapetti <https://github.com/loryman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export interface CoverageSummaryData {
lines: Totals;
statements: Totals;
branches: Totals;
functions: Totals;
}
export class CoverageSummary {
constructor(data: CoverageSummary | CoverageSummaryData);
merge(obj: CoverageSummary): CoverageSummary;
toJSON(): CoverageSummaryData;
isEmpty(): boolean;
data: CoverageSummaryData;
lines: Totals;
statements: Totals;
branches: Totals;
functions: Totals;
}
export interface CoverageMapData {
[key: string]: FileCoverage | FileCoverageData;
}
export class CoverageMap {
constructor(data: CoverageMapData | CoverageMap);
addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
files(): string[];
fileCoverageFor(filename: string): FileCoverage;
filter(callback: (key: string) => boolean): void;
getCoverageSummary(): CoverageSummary;
merge(data: CoverageMapData | CoverageMap): void;
toJSON(): CoverageMapData;
data: CoverageMapData;
}
export interface Location {
line: number;
column: number;
}
export interface Range {
start: Location;
end: Location;
}
export interface BranchMapping {
loc: Range;
type: string;
locations: Range[];
line: number;
}
export interface FunctionMapping {
name: string;
decl: Range;
loc: Range;
line: number;
}
export interface FileCoverageData {
path: string;
statementMap: { [key: string]: Range };
fnMap: { [key: string]: FunctionMapping };
branchMap: { [key: string]: BranchMapping };
s: { [key: string]: number };
f: { [key: string]: number };
b: { [key: string]: number[] };
}
export interface Totals {
total: number;
covered: number;
skipped: number;
pct: number;
}
export interface Coverage {
covered: number;
total: number;
coverage: number;
}
export class FileCoverage implements FileCoverageData {
constructor(data: string | FileCoverage | FileCoverageData);
merge(other: FileCoverageData): void;
getBranchCoverageByLine(): { [line: number]: Coverage };
getLineCoverage(): { [line: number]: number };
getUncoveredLines(): number[];
resetHits(): void;
computeBranchTotals(): Totals;
computeSimpleTotals(): Totals;
toSummary(): CoverageSummary;
toJSON(): object;
data: FileCoverageData;
path: string;
statementMap: { [key: string]: Range };
fnMap: { [key: string]: FunctionMapping };
branchMap: { [key: string]: BranchMapping };
s: { [key: string]: number };
f: { [key: string]: number };
b: { [key: string]: number[] };
}
export const classes: {
FileCoverage: FileCoverage;
};
export function createCoverageMap(data?: CoverageMap | CoverageMapData): CoverageMap;
export function createCoverageSummary(obj?: CoverageSummary | CoverageSummaryData): CoverageSummary;
export function createFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): FileCoverage;
{
"name": "@types/istanbul-lib-coverage",
"version": "2.0.3",
"description": "TypeScript definitions for istanbul-lib-coverage",
"license": "MIT",
"contributors": [
{
"name": "Jason Cheatham",
"url": "https://github.com/jason0x43",
"githubUsername": "jason0x43"
},
{
"name": "Lorenzo Rapetti",
"url": "https://github.com/loryman",
"githubUsername": "loryman"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/istanbul-lib-coverage"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "a951ff253666ffd402e5ddf6b7d5a359e22c9a6574f6a799a39e1e793107b647",
"typeScriptVersion": "3.0"
}
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/istanbul-lib-report`
# Summary
This package contains type definitions for istanbul-lib-report (https://istanbul.js.org).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-report.
### Additional Details
* Last updated: Tue, 21 Jan 2020 01:00:06 GMT
* Dependencies: [@types/istanbul-lib-coverage](https://npmjs.com/package/@types/istanbul-lib-coverage)
* Global values: none
# Credits
These definitions were written by Jason Cheatham (https://github.com/jason0x43), and Zacharias Björngren (https://github.com/zache).
// Type definitions for istanbul-lib-report 3.0
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
// Zacharias Björngren <https://github.com/zache>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import { CoverageMap, FileCoverage, CoverageSummary } from 'istanbul-lib-coverage';
/**
* returns a reporting context for the supplied options
*/
export function createContext(options?: Partial<ContextOptions>): Context;
/**
* returns the default watermarks that would be used when not
* overridden
*/
export function getDefaultWatermarks(): Watermarks;
export class ReportBase {
constructor(options?: Partial<ReportBaseOptions>);
execute(context: Context): void;
}
export interface ReportBaseOptions {
summarizer: Summarizers;
}
export type Summarizers = 'flat' | 'nested' | 'pkg' | 'defaultSummarizer';
export interface ContextOptions {
coverageMap: CoverageMap;
defaultSummarizer: Summarizers;
dir: string;
watermarks: Partial<Watermarks>;
sourceFinder(filepath: string): string;
}
export interface Context {
data: any;
dir: string;
sourceFinder(filepath: string): string;
watermarks: Watermarks;
writer: FileWriter;
/**
* returns the coverage class given a coverage
* types and a percentage value.
*/
classForPercent(type: keyof Watermarks, value: number): string;
/**
* returns the source code for the specified file path or throws if
* the source could not be found.
*/
getSource(filepath: string): string;
getTree(summarizer?: Summarizers): Tree;
/**
* returns a full visitor given a partial one.
*/
getVisitor<N extends Node = Node>(visitor: Partial<Visitor<N>>): Visitor<N>;
/**
* returns a FileWriter implementation for reporting use. Also available
* as the `writer` property on the context.
*/
getWriter(): FileWriter;
/**
* returns an XML writer for the supplied content writer
*/
getXmlWriter(contentWriter: ContentWriter): XmlWriter;
}
/**
* Base class for writing content
*/
export class ContentWriter {
/**
* returns the colorized version of a string. Typically,
* content writers that write to files will return the
* same string and ones writing to a tty will wrap it in
* appropriate escape sequences.
*/
colorize(str: string, clazz?: string): string;
/**
* writes a string appended with a newline to the destination
*/
println(str: string): void;
/**
* closes this content writer. Should be called after all writes are complete.
*/
close(): void;
}
/**
* a content writer that writes to a file
*/
export class FileContentWriter extends ContentWriter {
constructor(fileDescriptor: number);
write(str: string): void;
}
/**
* a content writer that writes to the console
*/
export class ConsoleWriter extends ContentWriter {
write(str: string): void;
}
/**
* utility for writing files under a specific directory
*/
export class FileWriter {
constructor(baseDir: string);
static startCapture(): void;
static stopCapture(): void;
static getOutput(): string;
static resetOutput(): void;
/**
* returns a FileWriter that is rooted at the supplied subdirectory
*/
writeForDir(subdir: string): FileWriter;
/**
* copies a file from a source directory to a destination name
*/
copyFile(source: string, dest: string, header?: string): void;
/**
* returns a content writer for writing content to the supplied file.
*/
writeFile(file: string | null): ContentWriter;
}
export interface XmlWriter {
indent(str: string): string;
/**
* writes the opening XML tag with the supplied attributes
*/
openTag(name: string, attrs?: any): void;
/**
* closes an open XML tag.
*/
closeTag(name: string): void;
/**
* writes a tag and its value opening and closing it at the same time
*/
inlineTag(name: string, attrs?: any, content?: string): void;
/**
* closes all open tags and ends the document
*/
closeAll(): void;
}
export type Watermark = [number, number];
export interface Watermarks {
statements: Watermark;
functions: Watermark;
branches: Watermark;
lines: Watermark;
}
export interface Node {
isRoot(): boolean;
visit(visitor: Visitor, state: any): void;
}
export interface ReportNode extends Node {
path: string;
parent: ReportNode | null;
fileCoverage: FileCoverage;
children: ReportNode[];
addChild(child: ReportNode): void;
asRelative(p: string): string;
getQualifiedName(): string;
getRelativeName(): string;
getParent(): Node;
getChildren(): Node[];
isSummary(): boolean;
getFileCoverage(): FileCoverage;
getCoverageSummary(filesOnly: boolean): CoverageSummary;
visit(visitor: Visitor<ReportNode>, state: any): void;
}
export interface Visitor<N extends Node = Node> {
onStart(root: N, state: any): void;
onSummary(root: N, state: any): void;
onDetail(root: N, state: any): void;
onSummaryEnd(root: N, state: any): void;
onEnd(root: N, state: any): void;
}
export interface Tree<N extends Node = Node> {
getRoot(): N;
visit(visitor: Partial<Visitor<N>>, state: any): void;
}
{
"name": "@types/istanbul-lib-report",
"version": "3.0.0",
"description": "TypeScript definitions for istanbul-lib-report",
"license": "MIT",
"contributors": [
{
"name": "Jason Cheatham",
"url": "https://github.com/jason0x43",
"githubUsername": "jason0x43"
},
{
"name": "Zacharias Björngren",
"url": "https://github.com/zache",
"githubUsername": "zache"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/istanbul-lib-report"
},
"scripts": {},
"dependencies": {
"@types/istanbul-lib-coverage": "*"
},
"typesPublisherContentHash": "f8b2f5e15a24d9f52a96c5cfadb0f582bf6200ce8643e15422c3c8f1a2bb1c63",
"typeScriptVersion": "2.8"
}
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/istanbul-reports`
# Summary
This package contains type definitions for istanbul-reports (https://github.com/istanbuljs/istanbuljs).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports/index.d.ts)
````ts
// Type definitions for istanbul-reports 3.0
// Project: https://github.com/istanbuljs/istanbuljs, https://istanbul.js.org
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
// Elena Shcherbakova <https://github.com/not-a-doctor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import { Node, ReportBase } from 'istanbul-lib-report';
export function create<T extends keyof ReportOptions>(name: T, options?: Partial<ReportOptions[T]>): ReportBase;
export interface FileOptions {
file: string;
}
export interface ProjectOptions {
projectRoot: string;
}
export interface ReportOptions {
clover: CloverOptions;
cobertura: CoberturaOptions;
'html-spa': HtmlSpaOptions;
html: HtmlOptions;
json: JsonOptions;
'json-summary': JsonSummaryOptions;
lcov: LcovOptions;
lcovonly: LcovOnlyOptions;
none: never;
teamcity: TeamcityOptions;
text: TextOptions;
'text-lcov': TextLcovOptions;
'text-summary': TextSummaryOptions;
}
export type ReportType = keyof ReportOptions;
export interface CloverOptions extends FileOptions, ProjectOptions {}
export interface CoberturaOptions extends FileOptions, ProjectOptions {}
export interface HtmlSpaOptions extends HtmlOptions {
metricsToShow: Array<'lines' | 'branches' | 'functions' | 'statements'>;
}
export interface HtmlOptions {
verbose: boolean;
skipEmpty: boolean;
subdir: string;
linkMapper: LinkMapper;
}
export type JsonOptions = FileOptions;
export type JsonSummaryOptions = FileOptions;
export interface LcovOptions extends FileOptions, ProjectOptions {}
export interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
export interface TeamcityOptions extends FileOptions {
blockName: string;
}
export interface TextOptions extends FileOptions {
maxCols: number;
skipEmpty: boolean;
skipFull: boolean;
}
export type TextLcovOptions = ProjectOptions;
export type TextSummaryOptions = FileOptions;
export interface LinkMapper {
getPath(node: string | Node): string;
relativePath(source: string | Node, target: string | Node): string;
assetPath(node: Node, name: string): string;
}
````
### Additional Details
* Last updated: Tue, 01 Jun 2021 21:02:19 GMT
* Dependencies: [@types/istanbul-lib-report](https://npmjs.com/package/@types/istanbul-lib-report)
* Global values: none
# Credits
These definitions were written by [Jason Cheatham](https://github.com/jason0x43), and [Elena Shcherbakova](https://github.com/not-a-doctor).
// Type definitions for istanbul-reports 3.0
// Project: https://github.com/istanbuljs/istanbuljs, https://istanbul.js.org
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
// Elena Shcherbakova <https://github.com/not-a-doctor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import { Node, ReportBase } from 'istanbul-lib-report';
export function create<T extends keyof ReportOptions>(name: T, options?: Partial<ReportOptions[T]>): ReportBase;
export interface FileOptions {
file: string;
}
export interface ProjectOptions {
projectRoot: string;
}
export interface ReportOptions {
clover: CloverOptions;
cobertura: CoberturaOptions;
'html-spa': HtmlSpaOptions;
html: HtmlOptions;
json: JsonOptions;
'json-summary': JsonSummaryOptions;
lcov: LcovOptions;
lcovonly: LcovOnlyOptions;
none: never;
teamcity: TeamcityOptions;
text: TextOptions;
'text-lcov': TextLcovOptions;
'text-summary': TextSummaryOptions;
}
export type ReportType = keyof ReportOptions;
export interface CloverOptions extends FileOptions, ProjectOptions {}
export interface CoberturaOptions extends FileOptions, ProjectOptions {}
export interface HtmlSpaOptions extends HtmlOptions {
metricsToShow: Array<'lines' | 'branches' | 'functions' | 'statements'>;
}
export interface HtmlOptions {
verbose: boolean;
skipEmpty: boolean;
subdir: string;
linkMapper: LinkMapper;
}
export type JsonOptions = FileOptions;
export type JsonSummaryOptions = FileOptions;
export interface LcovOptions extends FileOptions, ProjectOptions {}
export interface LcovOnlyOptions extends FileOptions, ProjectOptions {}
export interface TeamcityOptions extends FileOptions {
blockName: string;
}
export interface TextOptions extends FileOptions {
maxCols: number;
skipEmpty: boolean;
skipFull: boolean;
}
export type TextLcovOptions = ProjectOptions;
export type TextSummaryOptions = FileOptions;
export interface LinkMapper {
getPath(node: string | Node): string;
relativePath(source: string | Node, target: string | Node): string;
assetPath(node: Node, name: string): string;
}
{
"name": "@types/istanbul-reports",
"version": "3.0.1",
"description": "TypeScript definitions for istanbul-reports",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports",
"license": "MIT",
"contributors": [
{
"name": "Jason Cheatham",
"url": "https://github.com/jason0x43",
"githubUsername": "jason0x43"
},
{
"name": "Elena Shcherbakova",
"url": "https://github.com/not-a-doctor",
"githubUsername": "not-a-doctor"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/istanbul-reports"
},
"scripts": {},
"dependencies": {
"@types/istanbul-lib-report": "*"
},
"typesPublisherContentHash": "b331eb26db90bca3bd6f1e18a10a4f37631f149624847439756763800996e143",
"typeScriptVersion": "3.6"
}
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/jest`
# Summary
This package contains type definitions for Jest (https://jestjs.io/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest.
### Additional Details
* Last updated: Mon, 26 Apr 2021 11:01:22 GMT
* Dependencies: [@types/jest-diff](https://npmjs.com/package/@types/jest-diff), [@types/pretty-format](https://npmjs.com/package/@types/pretty-format)
* Global values: `afterAll`, `afterEach`, `beforeAll`, `beforeEach`, `describe`, `expect`, `fail`, `fdescribe`, `fit`, `it`, `jasmine`, `jest`, `pending`, `spyOn`, `test`, `xdescribe`, `xit`, `xtest`
# Credits
These definitions were written by [Asana (https://asana.com)
// Ivo Stratev](https://github.com/NoHomey), [jwbay](https://github.com/jwbay), [Alexey Svetliakov](https://github.com/asvetliakov), [Alex Jover Morales](https://github.com/alexjoverm), [Allan Lukwago](https://github.com/epicallan), [Ika](https://github.com/ikatyang), [Waseem Dahman](https://github.com/wsmd), [Jamie Mason](https://github.com/JamieMason), [Douglas Duteil](https://github.com/douglasduteil), [Ahn](https://github.com/ahnpnl), [Josh Goldberg](https://github.com/joshuakgoldberg), [Jeff Lau](https://github.com/UselessPickles), [Andrew Makarov](https://github.com/r3nya), [Martin Hochel](https://github.com/hotell), [Sebastian Sebald](https://github.com/sebald), [Andy](https://github.com/andys8), [Antoine Brault](https://github.com/antoinebrault), [Gregor Stamać](https://github.com/gstamac), [ExE Boss](https://github.com/ExE-Boss), [Alex Bolenok](https://github.com/quassnoi), [Mario Beltrán Alarcón](https://github.com/Belco90), [Tony Hallett](https://github.com/tonyhallett), [Jason Yu](https://github.com/ycmjason), [Devansh Jethmalani](https://github.com/devanshj), [Pawel Fajfer](https://github.com/pawfa), [Regev Brody](https://github.com/regevbr), and [Alexandre Germain](https://github.com/gerkindev).
// Type definitions for Jest 26.0
// Project: https://jestjs.io/
// Definitions by: Asana (https://asana.com)
// Ivo Stratev <https://github.com/NoHomey>
// jwbay <https://github.com/jwbay>
// Alexey Svetliakov <https://github.com/asvetliakov>
// Alex Jover Morales <https://github.com/alexjoverm>
// Allan Lukwago <https://github.com/epicallan>
// Ika <https://github.com/ikatyang>
// Waseem Dahman <https://github.com/wsmd>
// Jamie Mason <https://github.com/JamieMason>
// Douglas Duteil <https://github.com/douglasduteil>
// Ahn <https://github.com/ahnpnl>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Jeff Lau <https://github.com/UselessPickles>
// Andrew Makarov <https://github.com/r3nya>
// Martin Hochel <https://github.com/hotell>
// Sebastian Sebald <https://github.com/sebald>
// Andy <https://github.com/andys8>
// Antoine Brault <https://github.com/antoinebrault>
// Gregor Stamać <https://github.com/gstamac>
// ExE Boss <https://github.com/ExE-Boss>
// Alex Bolenok <https://github.com/quassnoi>
// Mario Beltrán Alarcón <https://github.com/Belco90>
// Tony Hallett <https://github.com/tonyhallett>
// Jason Yu <https://github.com/ycmjason>
// Devansh Jethmalani <https://github.com/devanshj>
// Pawel Fajfer <https://github.com/pawfa>
// Regev Brody <https://github.com/regevbr>
// Alexandre Germain <https://github.com/gerkindev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.8
declare var beforeAll: jest.Lifecycle;
declare var beforeEach: jest.Lifecycle;
declare var afterAll: jest.Lifecycle;
declare var afterEach: jest.Lifecycle;
declare var describe: jest.Describe;
declare var fdescribe: jest.Describe;
declare var xdescribe: jest.Describe;
declare var it: jest.It;
declare var fit: jest.It;
declare var xit: jest.It;
declare var test: jest.It;
declare var xtest: jest.It;
declare const expect: jest.Expect;
type ExtractEachCallbackArgs<T extends ReadonlyArray<any>> = {
1: [T[0]],
2: [T[0], T[1]],
3: [T[0], T[1], T[2]],
4: [T[0], T[1], T[2], T[3]],
5: [T[0], T[1], T[2], T[3], T[4]],
6: [T[0], T[1], T[2], T[3], T[4], T[5]],
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6]],
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7]],
9: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8]],
10: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], T[8], T[9]],
'fallback': Array<(T extends ReadonlyArray<infer U>? U: any)>
}[
T extends Readonly<[any]> ? 1
: T extends Readonly<[any, any]> ? 2
: T extends Readonly<[any, any, any]> ? 3
: T extends Readonly<[any, any, any, any]> ? 4
: T extends Readonly<[any, any, any, any, any]> ? 5
: T extends Readonly<[any, any, any, any, any, any]> ? 6
: T extends Readonly<[any, any, any, any, any, any, any]> ? 7
: T extends Readonly<[any, any, any, any, any, any, any, any]> ? 8
: T extends Readonly<[any, any, any, any, any, any, any, any, any]> ? 9
: T extends Readonly<[any, any, any, any, any, any, any, any, any, any]> ? 10
: 'fallback'
];
declare namespace jest {
/**
* Provides a way to add Jasmine-compatible matchers into your Jest context.
*/
function addMatchers(matchers: jasmine.CustomMatcherFactories): typeof jest;
/**
* Disables automatic mocking in the module loader.
*/
function autoMockOff(): typeof jest;
/**
* Enables automatic mocking in the module loader.
*/
function autoMockOn(): typeof jest;
/**
* Clears the mock.calls and mock.instances properties of all mocks.
* Equivalent to calling .mockClear() on every mocked function.
*/
function clearAllMocks(): typeof jest;
/**
* Use the automatic mocking system to generate a mocked version of the given module.
*/
// tslint:disable-next-line: no-unnecessary-generics
function createMockFromModule<T>(moduleName: string): T;
/**
* Resets the state of all mocks.
* Equivalent to calling .mockReset() on every mocked function.
*/
function resetAllMocks(): typeof jest;
/**
* available since Jest 21.1.0
* Restores all mocks back to their original value.
* Equivalent to calling .mockRestore on every mocked function.
* Beware that jest.restoreAllMocks() only works when mock was created with
* jest.spyOn; other mocks will require you to manually restore them.
*/
function restoreAllMocks(): typeof jest;
/**
* Removes any pending timers from the timer system. If any timers have
* been scheduled, they will be cleared and will never have the opportunity
* to execute in the future.
*/
function clearAllTimers(): typeof jest;
/**
* Returns the number of fake timers still left to run.
*/
function getTimerCount(): number;
/**
* Set the current system time used by fake timers. Simulates a user
* changing the system clock while your program is running. It affects the
* current time but it does not in itself cause e.g. timers to fire; they
* will fire exactly as they would have done without the call to
* jest.setSystemTime().
*
* > Note: This function is only available when using modern fake timers
* > implementation
*/
function setSystemTime(now?: number | Date): void;
/**
* When mocking time, Date.now() will also be mocked. If you for some
* reason need access to the real current time, you can invoke this
* function.
*
* > Note: This function is only available when using modern fake timers
* > implementation
*/
function getRealSystemTime(): number;
/**
* Indicates that the module system should never return a mocked version
* of the specified module, including all of the specificied module's dependencies.
*/
function deepUnmock(moduleName: string): typeof jest;
/**
* Disables automatic mocking in the module loader.
*/
function disableAutomock(): typeof jest;
/**
* Mocks a module with an auto-mocked version when it is being required.
*/
function doMock(moduleName: string, factory?: () => unknown, options?: MockOptions): typeof jest;
/**
* Indicates that the module system should never return a mocked version
* of the specified module from require() (e.g. that it should always return the real module).
*/
function dontMock(moduleName: string): typeof jest;
/**
* Enables automatic mocking in the module loader.
*/
function enableAutomock(): typeof jest;
/**
* Creates a mock function. Optionally takes a mock implementation.
*/
function fn(): Mock;
/**
* Creates a mock function. Optionally takes a mock implementation.
*/
function fn<T, Y extends any[]>(implementation?: (...args: Y) => T): Mock<T, Y>;
/**
* (renamed to `createMockFromModule` in Jest 26.0.0+)
* Use the automatic mocking system to generate a mocked version of the given module.
*/
// tslint:disable-next-line: no-unnecessary-generics
function genMockFromModule<T>(moduleName: string): T;
/**
* Returns whether the given function is a mock function.
*/
function isMockFunction(fn: any): fn is Mock;
/**
* Mocks a module with an auto-mocked version when it is being required.
*/
function mock(moduleName: string, factory?: () => unknown, options?: MockOptions): typeof jest;
/**
* Returns the actual module instead of a mock, bypassing all checks on
* whether the module should receive a mock implementation or not.
*/
// tslint:disable-next-line: no-unnecessary-generics
function requireActual<TModule extends {} = any>(moduleName: string): TModule;
/**
* Returns a mock module instead of the actual module, bypassing all checks
* on whether the module should be required normally or not.
*/
// tslint:disable-next-line: no-unnecessary-generics
function requireMock<TModule extends {} = any>(moduleName: string): TModule;
/**
* Resets the module registry - the cache of all required modules. This is
* useful to isolate modules where local state might conflict between tests.
*/
function resetModuleRegistry(): typeof jest;
/**
* Resets the module registry - the cache of all required modules. This is
* useful to isolate modules where local state might conflict between tests.
*/
function resetModules(): typeof jest;
/**
* Creates a sandbox registry for the modules that are loaded inside the callback function..
* This is useful to isolate specific modules for every test so that local module state doesn't conflict between tests.
*/
function isolateModules(fn: () => void): typeof jest;
/**
* Runs failed tests n-times until they pass or until the max number of retries is exhausted.
* This only works with jest-circus!
*/
function retryTimes(numRetries: number): typeof jest;
/**
* Exhausts tasks queued by setImmediate().
*/
function runAllImmediates(): typeof jest;
/**
* Exhausts the micro-task queue (usually interfaced in node via process.nextTick).
*/
function runAllTicks(): typeof jest;
/**
* Exhausts the macro-task queue (i.e., all tasks queued by setTimeout() and setInterval()).
*/
function runAllTimers(): typeof jest;
/**
* Executes only the macro-tasks that are currently pending (i.e., only the
* tasks that have been queued by setTimeout() or setInterval() up to this point).
* If any of the currently pending macro-tasks schedule new macro-tasks,
* those new tasks will not be executed by this call.
*/
function runOnlyPendingTimers(): typeof jest;
/**
* (renamed to `advanceTimersByTime` in Jest 21.3.0+) Executes only the macro
* task queue (i.e. all tasks queued by setTimeout() or setInterval() and setImmediate()).
*/
function runTimersToTime(msToRun: number): typeof jest;
/**
* Advances all timers by msToRun milliseconds. All pending "macro-tasks" that have been
* queued via setTimeout() or setInterval(), and would be executed within this timeframe
* will be executed.
*/
function advanceTimersByTime(msToRun: number): typeof jest;
/**
* 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.
*/
function advanceTimersToNextTimer(step?: number): void;
/**
* Explicitly supplies the mock object that the module system should return
* for the specified module.
*/
// tslint:disable-next-line: no-unnecessary-generics
function setMock<T>(moduleName: string, moduleExports: T): typeof jest;
/**
* Set the default timeout interval for tests and before/after hooks in milliseconds.
* Note: The default timeout interval is 5 seconds if this method is not called.
*/
function setTimeout(timeout: number): typeof jest;
/**
* Creates a mock function similar to jest.fn but also tracks calls to `object[methodName]`
*
* Note: By default, jest.spyOn also calls the spied method. This is different behavior from most
* other test libraries.
*
* @example
*
* const video = require('./video');
*
* test('plays video', () => {
* const spy = jest.spyOn(video, 'play');
* const isPlaying = video.play();
*
* expect(spy).toHaveBeenCalled();
* expect(isPlaying).toBe(true);
*
* spy.mockReset();
* spy.mockRestore();
* });
*/
function spyOn<T extends {}, M extends NonFunctionPropertyNames<Required<T>>>(
object: T,
method: M,
accessType: 'get'
): SpyInstance<Required<T>[M], []>;
function spyOn<T extends {}, M extends NonFunctionPropertyNames<Required<T>>>(
object: T,
method: M,
accessType: 'set'
): SpyInstance<void, [Required<T>[M]]>;
function spyOn<T extends {}, M extends FunctionPropertyNames<Required<T>>>(
object: T,
method: M
): Required<T>[M] extends (...args: any[]) => any
? SpyInstance<ReturnType<Required<T>[M]>, ArgsType<Required<T>[M]>>
: never;
function spyOn<T extends {}, M extends ConstructorPropertyNames<Required<T>>>(
object: T,
method: M
): Required<T>[M] extends new (...args: any[]) => any
? SpyInstance<InstanceType<Required<T>[M]>, ConstructorArgsType<Required<T>[M]>>
: never;
/**
* Indicates that the module system should never return a mocked version of
* the specified module from require() (e.g. that it should always return the real module).
*/
function unmock(moduleName: string): typeof jest;
/**
* Instructs Jest to use fake versions of the standard timer functions.
*/
function useFakeTimers(implementation?: 'modern' | 'legacy'): typeof jest;
/**
* Instructs Jest to use the real versions of the standard timer functions.
*/
function useRealTimers(): typeof jest;
interface MockOptions {
virtual?: boolean;
}
type EmptyFunction = () => void;
type ArgsType<T> = T extends (...args: infer A) => any ? A : never;
type ConstructorArgsType<T> = T extends new (...args: infer A) => any ? A : never;
type RejectedValue<T> = T extends PromiseLike<any> ? any : never;
type ResolvedValue<T> = T extends PromiseLike<infer U> ? U | T : never;
// see https://github.com/Microsoft/TypeScript/issues/25215
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K }[keyof T] &
string;
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never }[keyof T] &
string;
type ConstructorPropertyNames<T> = { [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never }[keyof T] &
string;
interface DoneCallback {
(...args: any[]): any;
fail(error?: string | { message: string }): any;
}
type ProvidesCallback = (cb: DoneCallback) => any;
type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any;
interface FunctionLike {
readonly name: string;
}
interface Each {
// Exclusively arrays.
<T extends any[] | [any]>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T) => any, timeout?: number) => void;
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => any, timeout?: number) => void;
// Not arrays.
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => any, timeout?: number) => void;
(cases: ReadonlyArray<ReadonlyArray<any>>): (
name: string,
fn: (...args: any[]) => any,
timeout?: number
) => void;
(strings: TemplateStringsArray, ...placeholders: any[]): (
name: string,
fn: (arg: any) => any,
timeout?: number
) => void;
}
/**
* Creates a test closure
*/
interface It {
/**
* Creates a test closure.
*
* @param name The name of your test
* @param fn The function for your test
* @param timeout The timeout for an async function test
*/
(name: string, fn?: ProvidesCallback, timeout?: number): void;
/**
* Only runs this test in the current file.
*/
only: It;
/**
* Skips running this test in the current file.
*/
skip: It;
/**
* Sketch out which tests to write in the future.
*/
todo: It;
/**
* Experimental and should be avoided.
*/
concurrent: It;
/**
* Use if you keep duplicating the same test with different data. `.each` allows you to write the
* test once and pass data in.
*
* `.each` is available with two APIs:
*
* #### 1 `test.each(table)(name, fn)`
*
* - `table`: Array of Arrays with the arguments that are passed into the test fn for each row.
* - `name`: String the title of the test block.
* - `fn`: Function the test to be ran, this is the function that will receive the parameters in each row as function arguments.
*
*
* #### 2 `test.each table(name, fn)`
*
* - `table`: Tagged Template Literal
* - `name`: String the title of the test, use `$variable` to inject test data into the test title from the tagged template expressions.
* - `fn`: Function the test to be ran, this is the function that will receive the test data object..
*
* @example
*
* // API 1
* test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
* '.add(%i, %i)',
* (a, b, expected) => {
* expect(a + b).toBe(expected);
* },
* );
*
* // API 2
* test.each`
* a | b | expected
* ${1} | ${1} | ${2}
* ${1} | ${2} | ${3}
* ${2} | ${1} | ${3}
* `('returns $expected when $a is added $b', ({a, b, expected}) => {
* expect(a + b).toBe(expected);
* });
*
*/
each: Each;
}
interface Describe {
// tslint:disable-next-line ban-types
(name: number | string | Function | FunctionLike, fn: EmptyFunction): void;
/** Only runs the tests inside this `describe` for the current file */
only: Describe;
/** Skips running the tests inside this `describe` for the current file */
skip: Describe;
each: Each;
}
type PrintLabel = (string: string) => string;
type MatcherHintColor = (arg: string) => string;
interface MatcherHintOptions {
comment?: string;
expectedColor?: MatcherHintColor;
isDirectExpectCall?: boolean;
isNot?: boolean;
promise?: string;
receivedColor?: MatcherHintColor;
secondArgument?: string;
secondArgumentColor?: MatcherHintColor;
}
interface ChalkFunction {
(text: TemplateStringsArray, ...placeholders: any[]): string;
(...text: any[]): string;
}
interface ChalkColorSupport {
level: 0 | 1 | 2 | 3;
hasBasic: boolean;
has256: boolean;
has16m: boolean;
}
type MatcherColorFn = ChalkFunction & { supportsColor: ChalkColorSupport };
type EqualityTester = (a: any, b: any) => boolean | undefined;
interface MatcherUtils {
readonly isNot: boolean;
readonly dontThrow: () => void;
readonly promise: string;
readonly assertionCalls: number;
readonly expectedAssertionsNumber: number | null;
readonly isExpectingAssertions: boolean;
readonly suppressedErrors: any[];
readonly expand: boolean;
readonly testPath: string;
readonly currentTestName: string;
utils: {
readonly EXPECTED_COLOR: MatcherColorFn;
readonly RECEIVED_COLOR: MatcherColorFn;
readonly INVERTED_COLOR: MatcherColorFn;
readonly BOLD_WEIGHT: MatcherColorFn;
readonly DIM_COLOR: MatcherColorFn;
readonly SUGGEST_TO_CONTAIN_EQUAL: string;
diff(a: any, b: any, options?: import("jest-diff").DiffOptions): string | null;
ensureActualIsNumber(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureExpectedIsNumber(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureNoExpected(actual: any, matcherName: string, options?: MatcherHintOptions): void;
ensureNumbers(actual: any, expected: any, matcherName: string, options?: MatcherHintOptions): void;
ensureExpectedIsNonNegativeInteger(expected: any, matcherName: string, options?: MatcherHintOptions): void;
matcherHint(
matcherName: string,
received?: string,
expected?: string,
options?: MatcherHintOptions
): string;
matcherErrorMessage(
hint: string,
generic: string,
specific: string
): string;
pluralize(word: string, count: number): string;
printReceived(object: any): string;
printExpected(value: any): string;
printWithType(name: string, value: any, print: (value: any) => string): string;
stringify(object: {}, maxDepth?: number): string;
highlightTrailingWhitespace(text: string): string;
printDiffOrStringify(expected: any, received: any, expectedLabel: string, receivedLabel: string, expand: boolean): string;
getLabelPrinter(...strings: string[]): PrintLabel;
iterableEquality: EqualityTester;
subsetEquality: EqualityTester;
};
/**
* This is a deep-equality function that will return true if two objects have the same values (recursively).
*/
equals(a: any, b: any, customTesters?: EqualityTester[], strictCheck?: boolean): boolean;
[other: string]: any;
}
interface ExpectExtendMap {
[key: string]: CustomMatcher;
}
type MatcherContext = MatcherUtils & Readonly<MatcherState>;
type CustomMatcher = (
this: MatcherContext,
received: any,
...actual: any[]
) => CustomMatcherResult | Promise<CustomMatcherResult>;
interface CustomMatcherResult {
pass: boolean;
message: () => string;
}
type SnapshotSerializerPlugin = import('pretty-format').Plugin;
interface InverseAsymmetricMatchers {
/**
* `expect.not.arrayContaining(array)` matches a received array which
* does not contain all of the elements in the expected array. That is,
* the expected array is not a subset of the received array. It is the
* inverse of `expect.arrayContaining`.
*
* Optionally, you can provide a type for the elements via a generic.
*/
// tslint:disable-next-line: no-unnecessary-generics
arrayContaining<E = any>(arr: E[]): any;
/**
* `expect.not.objectContaining(object)` matches any received object
* that does not recursively match the expected properties. That is, the
* expected object is not a subset of the received object. Therefore,
* it matches a received object which contains properties that are not
* in the expected object. It is the inverse of `expect.objectContaining`.
*
* Optionally, you can provide a type for the object via a generic.
* This ensures that the object contains the desired structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
objectContaining<E = {}>(obj: E): any;
/**
* `expect.not.stringMatching(string | regexp)` matches the received
* string that does not match the expected regexp. It is the inverse of
* `expect.stringMatching`.
*/
stringMatching(str: string | RegExp): any;
/**
* `expect.not.stringContaining(string)` matches the received string
* that does not contain the exact expected string. It is the inverse of
* `expect.stringContaining`.
*/
stringContaining(str: string): any;
}
interface MatcherState {
assertionCalls: number;
currentTestName: string;
expand: boolean;
expectedAssertionsNumber: number;
isExpectingAssertions?: boolean;
suppressedErrors: Error[];
testPath: string;
}
/**
* The `expect` function is used every time you want to test a value.
* You will rarely call `expect` by itself.
*/
interface Expect {
/**
* The `expect` function is used every time you want to test a value.
* You will rarely call `expect` by itself.
*
* @param actual The value to apply matchers against.
*/
<T = any>(actual: T): JestMatchers<T>;
/**
* Matches anything but null or undefined. You can use it inside `toEqual` or `toBeCalledWith` instead
* of a literal value. For example, if you want to check that a mock function is called with a
* non-null argument:
*
* @example
*
* test('map calls its argument with a non-null argument', () => {
* const mock = jest.fn();
* [1].map(x => mock(x));
* expect(mock).toBeCalledWith(expect.anything());
* });
*
*/
anything(): any;
/**
* Matches anything that was created with the given constructor.
* You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
*
* @example
*
* function randocall(fn) {
* return fn(Math.floor(Math.random() * 6 + 1));
* }
*
* test('randocall calls its callback with a number', () => {
* const mock = jest.fn();
* randocall(mock);
* expect(mock).toBeCalledWith(expect.any(Number));
* });
*/
any(classType: any): any;
/**
* Matches any array made up entirely of elements in the provided array.
* You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
*
* Optionally, you can provide a type for the elements via a generic.
*/
// tslint:disable-next-line: no-unnecessary-generics
arrayContaining<E = any>(arr: E[]): any;
/**
* Verifies that a certain number of assertions are called during a test.
* This is often useful when testing asynchronous code, in order to
* make sure that assertions in a callback actually got called.
*/
assertions(num: number): void;
/**
* Verifies that at least one assertion is called during a test.
* This is often useful when testing asynchronous code, in order to
* make sure that assertions in a callback actually got called.
*/
hasAssertions(): void;
/**
* You can use `expect.extend` to add your own matchers to Jest.
*/
extend(obj: ExpectExtendMap): void;
/**
* Adds a module to format application-specific data structures for serialization.
*/
addSnapshotSerializer(serializer: SnapshotSerializerPlugin): void;
/**
* Matches any object that recursively matches the provided keys.
* This is often handy in conjunction with other asymmetric matchers.
*
* Optionally, you can provide a type for the object via a generic.
* This ensures that the object contains the desired structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
objectContaining<E = {}>(obj: E): any;
/**
* Matches any string that contains the exact provided string
*/
stringMatching(str: string | RegExp): any;
/**
* Matches any received string that contains the exact expected string
*/
stringContaining(str: string): any;
not: InverseAsymmetricMatchers;
setState(state: object): void;
getState(): MatcherState & Record<string, any>;
}
type JestMatchers<T> = JestMatchersShape<Matchers<void, T>, Matchers<Promise<void>, T>>;
type JestMatchersShape<TNonPromise extends {} = {}, TPromise extends {} = {}> = {
/**
* Use resolves to unwrap the value of a fulfilled promise so any other
* matcher can be chained. If the promise is rejected the assertion fails.
*/
resolves: AndNot<TPromise>,
/**
* Unwraps the reason of a rejected promise so any other matcher can be chained.
* If the promise is fulfilled the assertion fails.
*/
rejects: AndNot<TPromise>
} & AndNot<TNonPromise>;
type AndNot<T> = T & {
not: T
};
// should be R extends void|Promise<void> but getting dtslint error
interface Matchers<R, T = {}> {
/**
* Ensures the last call to a mock function was provided specific args.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
lastCalledWith<E extends any[]>(...args: E): R;
/**
* Ensure that the last call to a mock function has returned a specified value.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
lastReturnedWith<E = any>(value: E): R;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
nthCalledWith<E extends any[]>(nthCall: number, ...params: E): R;
/**
* Ensure that the nth call to a mock function has returned a specified value.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
nthReturnedWith<E = any>(n: number, value: E): R;
/**
* Checks that a value is what you expect. It uses `Object.is` to check strict equality.
* Don't use `toBe` with floating-point numbers.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toBe<E = any>(expected: E): R;
/**
* Ensures that a mock function is called.
*/
toBeCalled(): R;
/**
* Ensures that a mock function is called an exact number of times.
*/
toBeCalledTimes(expected: number): R;
/**
* Ensure that a mock function is called with specific arguments.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
toBeCalledWith<E extends any[]>(...args: E): R;
/**
* Using exact equality with floating point numbers is a bad idea.
* Rounding means that intuitive things fail.
* The default for numDigits is 2.
*/
toBeCloseTo(expected: number, numDigits?: number): R;
/**
* Ensure that a variable is not undefined.
*/
toBeDefined(): R;
/**
* When you don't care what a value is, you just want to
* ensure a value is false in a boolean context.
*/
toBeFalsy(): R;
/**
* For comparing floating point or big integer numbers.
*/
toBeGreaterThan(expected: number | bigint): R;
/**
* For comparing floating point or big integer numbers.
*/
toBeGreaterThanOrEqual(expected: number | bigint): R;
/**
* Ensure that an object is an instance of a class.
* This matcher uses `instanceof` underneath.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toBeInstanceOf<E = any>(expected: E): R;
/**
* For comparing floating point or big integer numbers.
*/
toBeLessThan(expected: number | bigint): R;
/**
* For comparing floating point or big integer numbers.
*/
toBeLessThanOrEqual(expected: number | bigint): R;
/**
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
* So use `.toBeNull()` when you want to check that something is null.
*/
toBeNull(): R;
/**
* Use when you don't care what a value is, you just want to ensure a value
* is true in a boolean context. In JavaScript, there are six falsy values:
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
*/
toBeTruthy(): R;
/**
* Used to check that a variable is undefined.
*/
toBeUndefined(): R;
/**
* Used to check that a variable is NaN.
*/
toBeNaN(): R;
/**
* Used when you want to check that an item is in a list.
* For testing the items in the list, this uses `===`, a strict equality check.
* It can also check whether a string is a substring of another string.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toContain<E = any>(expected: E): R;
/**
* Used when you want to check that an item is in a list.
* For testing the items in the list, this matcher recursively checks the
* equality of all fields, rather than checking for object identity.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toContainEqual<E = any>(expected: E): R;
/**
* Used when you want to check that two objects have the same value.
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toEqual<E = any>(expected: E): R;
/**
* Ensures that a mock function is called.
*/
toHaveBeenCalled(): R;
/**
* Ensures that a mock function is called an exact number of times.
*/
toHaveBeenCalledTimes(expected: number): R;
/**
* Ensure that a mock function is called with specific arguments.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveBeenCalledWith<E extends any[]>(...params: E): R;
/**
* Ensure that a mock function is called with specific arguments on an Nth call.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveBeenNthCalledWith<E extends any[]>(nthCall: number, ...params: E): R;
/**
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
* to test what arguments it was last called with.
*
* Optionally, you can provide a type for the expected arguments via a generic.
* Note that the type must be either an array or a tuple.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveBeenLastCalledWith<E extends any[]>(...params: E): R;
/**
* Use to test the specific value that a mock function last returned.
* If the last call to the mock function threw an error, then this matcher will fail
* no matter what value you provided as the expected return value.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveLastReturnedWith<E = any>(expected: E): R;
/**
* Used to check that an object has a `.length` property
* and it is set to a certain numeric value.
*/
toHaveLength(expected: number): R;
/**
* Use to test the specific value that a mock function returned for the nth call.
* If the nth call to the mock function threw an error, then this matcher will fail
* no matter what value you provided as the expected return value.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveNthReturnedWith<E = any>(nthCall: number, expected: E): R;
/**
* Use to check if property at provided reference keyPath exists for an object.
* For checking deeply nested properties in an object you may use dot notation or an array containing
* the keyPath for deep references.
*
* Optionally, you can provide a value to check if it's equal to the value present at keyPath
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
* the equality of all fields.
*
* @example
*
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveProperty<E = any>(propertyPath: string | any[], value?: E): R;
/**
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
*/
toHaveReturned(): R;
/**
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
*/
toHaveReturnedTimes(expected: number): R;
/**
* Use to ensure that a mock function returned a specific value.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toHaveReturnedWith<E = any>(expected: E): R;
/**
* Check that a string matches a regular expression.
*/
toMatch(expected: string | RegExp): R;
/**
* Used to check that a JavaScript object matches a subset of the properties of an object
*
* Optionally, you can provide an object to use as Generic type for the expected value.
* This ensures that the matching object matches the structure of the provided object-like type.
*
* @example
*
* type House = {
* bath: boolean;
* bedrooms: number;
* kitchen: {
* amenities: string[];
* area: number;
* wallColor: string;
* }
* };
*
* expect(desiredHouse).toMatchObject<House>({...standardHouse, kitchen: {area: 20}}) // wherein standardHouse is some base object of type House
*/
// tslint:disable-next-line: no-unnecessary-generics
toMatchObject<E extends {} | any[]>(expected: E): R;
/**
* This ensures that a value matches the most recent snapshot with property matchers.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
// tslint:disable-next-line: no-unnecessary-generics
toMatchSnapshot<U extends { [P in keyof T]: any }>(propertyMatchers: Partial<U>, snapshotName?: string): R;
/**
* This ensures that a value matches the most recent snapshot.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
toMatchSnapshot(snapshotName?: string): R;
/**
* This ensures that a value matches the most recent snapshot with property matchers.
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
// tslint:disable-next-line: no-unnecessary-generics
toMatchInlineSnapshot<U extends { [P in keyof T]: any }>(propertyMatchers: Partial<U>, snapshot?: string): R;
/**
* This ensures that a value matches the most recent snapshot with property matchers.
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
*/
toMatchInlineSnapshot(snapshot?: string): R;
/**
* Ensure that a mock function has returned (as opposed to thrown) at least once.
*/
toReturn(): R;
/**
* Ensure that a mock function has returned (as opposed to thrown) a specified number of times.
*/
toReturnTimes(count: number): R;
/**
* Ensure that a mock function has returned a specified value at least once.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toReturnWith<E = any>(value: E): R;
/**
* Use to test that objects have the same types as well as structure.
*
* Optionally, you can provide a type for the expected value via a generic.
* This is particularly useful for ensuring expected objects have the right structure.
*/
// tslint:disable-next-line: no-unnecessary-generics
toStrictEqual<E = any>(expected: E): R;
/**
* Used to test that a function throws when it is called.
*/
toThrow(error?: string | Constructable | RegExp | Error): R;
/**
* If you want to test that a specific error is thrown inside a function.
*/
toThrowError(error?: string | Constructable | RegExp | Error): R;
/**
* Used to test that a function throws a error matching the most recent snapshot when it is called.
*/
toThrowErrorMatchingSnapshot(snapshotName?: string): R;
/**
* Used to test that a function throws a error matching the most recent snapshot when it is called.
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
*/
toThrowErrorMatchingInlineSnapshot(snapshot?: string): R;
}
type RemoveFirstFromTuple<T extends any[]> =
T['length'] extends 0 ? [] :
(((...b: T) => void) extends (a: any, ...b: infer I) => void ? I : []);
interface AsymmetricMatcher {
asymmetricMatch(other: unknown): boolean;
}
type NonAsyncMatchers<TMatchers extends ExpectExtendMap> = {
[K in keyof TMatchers]: ReturnType<TMatchers[K]> extends Promise<CustomMatcherResult>? never: K
}[keyof TMatchers];
type CustomAsyncMatchers<TMatchers extends ExpectExtendMap> = {[K in NonAsyncMatchers<TMatchers>]: CustomAsymmetricMatcher<TMatchers[K]>};
type CustomAsymmetricMatcher<TMatcher extends (...args: any[]) => any> = (...args: RemoveFirstFromTuple<Parameters<TMatcher>>) => AsymmetricMatcher;
// should be TMatcherReturn extends void|Promise<void> but getting dtslint error
type CustomJestMatcher<TMatcher extends (...args: any[]) => any, TMatcherReturn> = (...args: RemoveFirstFromTuple<Parameters<TMatcher>>) => TMatcherReturn;
type ExpectProperties= {
[K in keyof Expect]: Expect[K]
};
// should be TMatcherReturn extends void|Promise<void> but getting dtslint error
// Use the `void` type for return types only. Otherwise, use `undefined`. See: https://github.com/Microsoft/dtslint/blob/master/docs/void-return.md
// have added issue https://github.com/microsoft/dtslint/issues/256 - Cannot have type union containing void ( to be used as return type only
type ExtendedMatchers<TMatchers extends ExpectExtendMap, TMatcherReturn, TActual> = Matchers<TMatcherReturn, TActual> & {[K in keyof TMatchers]: CustomJestMatcher<TMatchers[K], TMatcherReturn>};
type JestExtendedMatchers<TMatchers extends ExpectExtendMap, TActual> = JestMatchersShape<ExtendedMatchers<TMatchers, void, TActual>, ExtendedMatchers<TMatchers, Promise<void>, TActual>>;
// when have called expect.extend
type ExtendedExpectFunction<TMatchers extends ExpectExtendMap> = <TActual>(actual: TActual) => JestExtendedMatchers<TMatchers, TActual>;
type ExtendedExpect<TMatchers extends ExpectExtendMap>=
ExpectProperties &
AndNot<CustomAsyncMatchers<TMatchers>> &
ExtendedExpectFunction<TMatchers>;
type NonPromiseMatchers<T extends JestMatchersShape<any>> = Omit<T, 'resolves' | 'rejects' | 'not'>;
type PromiseMatchers<T extends JestMatchersShape> = Omit<T['resolves'], 'not'>;
interface Constructable {
new (...args: any[]): any;
}
interface Mock<T = any, Y extends any[] = any> extends Function, MockInstance<T, Y> {
new (...args: Y): T;
(...args: Y): T;
}
interface SpyInstance<T = any, Y extends any[] = any> extends MockInstance<T, Y> {}
/**
* Represents a function that has been spied on.
*/
type SpiedFunction<T extends (...args: any[]) => any> = SpyInstance<ReturnType<T>, ArgsType<T>>;
/**
* Wrap a function with mock definitions
*
* @example
*
* import { myFunction } from "./library";
* jest.mock("./library");
*
* const mockMyFunction = myFunction as jest.MockedFunction<typeof myFunction>;
* expect(mockMyFunction.mock.calls[0][0]).toBe(42);
*/
type MockedFunction<T extends (...args: any[]) => any> = MockInstance<ReturnType<T>, ArgsType<T>> & T;
/**
* Wrap a class with mock definitions
*
* @example
*
* import { MyClass } from "./library";
* jest.mock("./library");
*
* const mockedMyClass = MyClass as jest.MockedClass<typeof MyClass>;
*
* expect(mockedMyClass.mock.calls[0][0]).toBe(42); // Constructor calls
* expect(mockedMyClass.prototype.myMethod.mock.calls[0][0]).toBe(42); // Method calls
*/
type MockedClass<T extends Constructable> = MockInstance<
InstanceType<T>,
T extends new (...args: infer P) => any ? P : never
> & {
prototype: T extends { prototype: any } ? Mocked<T['prototype']> : never;
} & T;
/**
* Wrap an object or a module with mock definitions
*
* @example
*
* jest.mock("../api");
* import * as api from "../api";
*
* const mockApi = api as jest.Mocked<typeof api>;
* api.MyApi.prototype.myApiMethod.mockImplementation(() => "test");
*/
type Mocked<T> = {
[P in keyof T]: T[P] extends (...args: any[]) => any
? MockInstance<ReturnType<T[P]>, ArgsType<T[P]>>
: T[P] extends Constructable
? MockedClass<T[P]>
: T[P]
} &
T;
interface MockInstance<T, Y extends any[]> {
/** Returns the mock name string set by calling `mockFn.mockName(value)`. */
getMockName(): string;
/** Provides access to the mock's metadata */
mock: MockContext<T, Y>;
/**
* Resets all information stored in the mockFn.mock.calls and mockFn.mock.instances arrays.
*
* Often this is useful when you want to clean up a mock's usage data between two assertions.
*
* Beware that `mockClear` will replace `mockFn.mock`, not just `mockFn.mock.calls` and `mockFn.mock.instances`.
* You should therefore avoid assigning mockFn.mock to other variables, temporary or not, to make sure you
* don't access stale data.
*/
mockClear(): this;
/**
* Resets all information stored in the mock, including any initial implementation and mock name given.
*
* This is useful when you want to completely restore a mock back to its initial state.
*
* Beware that `mockReset` will replace `mockFn.mock`, not just `mockFn.mock.calls` and `mockFn.mock.instances`.
* You should therefore avoid assigning mockFn.mock to other variables, temporary or not, to make sure you
* don't access stale data.
*/
mockReset(): this;
/**
* Does everything that `mockFn.mockReset()` does, and also restores the original (non-mocked) implementation.
*
* This is useful when you want to mock functions in certain test cases and restore the original implementation in others.
*
* Beware that `mockFn.mockRestore` only works when mock was created with `jest.spyOn`. Thus you have to take care of restoration
* yourself when manually assigning `jest.fn()`.
*
* The [`restoreMocks`](https://jestjs.io/docs/en/configuration.html#restoremocks-boolean) configuration option is available
* to restore mocks automatically between tests.
*/
mockRestore(): void;
/**
* Returns the function that was set as the implementation of the mock (using mockImplementation).
*/
getMockImplementation(): ((...args: Y) => T) | undefined;
/**
* Accepts a function that should be used as the implementation of the mock. The mock itself will still record
* all calls that go into and instances that come from itself – the only difference is that the implementation
* will also be executed when the mock is called.
*
* Note: `jest.fn(implementation)` is a shorthand for `jest.fn().mockImplementation(implementation)`.
*/
mockImplementation(fn?: (...args: Y) => T): this;
/**
* Accepts a function that will be used as an implementation of the mock for one call to the mocked function.
* Can be chained so that multiple function calls produce different results.
*
* @example
*
* const myMockFn = jest
* .fn()
* .mockImplementationOnce(cb => cb(null, true))
* .mockImplementationOnce(cb => cb(null, false));
*
* myMockFn((err, val) => console.log(val)); // true
*
* myMockFn((err, val) => console.log(val)); // false
*/
mockImplementationOnce(fn: (...args: Y) => T): this;
/** Sets the name of the mock`. */
mockName(name: string): this;
/**
* Just a simple sugar function for:
*
* @example
*
* jest.fn(function() {
* return this;
* });
*/
mockReturnThis(): this;
/**
* Accepts a value that will be returned whenever the mock function is called.
*
* @example
*
* const mock = jest.fn();
* mock.mockReturnValue(42);
* mock(); // 42
* mock.mockReturnValue(43);
* mock(); // 43
*/
mockReturnValue(value: T): this;
/**
* Accepts a value that will be returned for one call to the mock function. Can be chained so that
* successive calls to the mock function return different values. When there are no more
* `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.
*
* @example
*
* const myMockFn = jest.fn()
* .mockReturnValue('default')
* .mockReturnValueOnce('first call')
* .mockReturnValueOnce('second call');
*
* // 'first call', 'second call', 'default', 'default'
* console.log(myMockFn(), myMockFn(), myMockFn(), myMockFn());
*
*/
mockReturnValueOnce(value: T): this;
/**
* Simple sugar function for: `jest.fn().mockImplementation(() => Promise.resolve(value));`
*/
mockResolvedValue(value: ResolvedValue<T>): this;
/**
* Simple sugar function for: `jest.fn().mockImplementationOnce(() => Promise.resolve(value));`
*
* @example
*
* test('async test', async () => {
* const asyncMock = jest
* .fn()
* .mockResolvedValue('default')
* .mockResolvedValueOnce('first call')
* .mockResolvedValueOnce('second call');
*
* await asyncMock(); // first call
* await asyncMock(); // second call
* await asyncMock(); // default
* await asyncMock(); // default
* });
*
*/
mockResolvedValueOnce(value: ResolvedValue<T>): this;
/**
* Simple sugar function for: `jest.fn().mockImplementation(() => Promise.reject(value));`
*
* @example
*
* test('async test', async () => {
* const asyncMock = jest.fn().mockRejectedValue(new Error('Async error'));
*
* await asyncMock(); // throws "Async error"
* });
*/
mockRejectedValue(value: RejectedValue<T>): this;
/**
* Simple sugar function for: `jest.fn().mockImplementationOnce(() => Promise.reject(value));`
*
* @example
*
* test('async test', async () => {
* const asyncMock = jest
* .fn()
* .mockResolvedValueOnce('first call')
* .mockRejectedValueOnce(new Error('Async error'));
*
* await asyncMock(); // first call
* await asyncMock(); // throws "Async error"
* });
*
*/
mockRejectedValueOnce(value: RejectedValue<T>): this;
}
/**
* Represents the result of a single call to a mock function with a return value.
*/
interface MockResultReturn<T> {
type: 'return';
value: T;
}
/**
* Represents the result of a single incomplete call to a mock function.
*/
interface MockResultIncomplete {
type: 'incomplete';
value: undefined;
}
/**
* Represents the result of a single call to a mock function with a thrown error.
*/
interface MockResultThrow {
type: 'throw';
value: any;
}
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
interface MockContext<T, Y extends any[]> {
calls: Y[];
instances: T[];
invocationCallOrder: number[];
/**
* List of results of calls to the mock function.
*/
results: Array<MockResult<T>>;
}
}
// Jest ships with a copy of Jasmine. They monkey-patch its APIs and divergence/deprecation are expected.
// Relevant parts of Jasmine's API are below so they can be changed and removed over time.
// This file can't reference jasmine.d.ts since the globals aren't compatible.
declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
/**
* If you call the function pending anywhere in the spec body,
* no matter the expectations, the spec will be marked pending.
*/
declare function pending(reason?: string): void;
/**
* Fails a test when called within one.
*/
declare function fail(error?: any): never;
declare namespace jasmine {
let DEFAULT_TIMEOUT_INTERVAL: number;
function clock(): Clock;
function any(aclass: any): Any;
function anything(): Any;
function arrayContaining(sample: any[]): ArrayContaining;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name?: string, originalFn?: (...args: any[]) => any): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
// tslint:disable-next-line: no-unnecessary-generics
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
function pp(value: any): string;
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
function addMatchers(matchers: CustomMatcherFactories): void;
function stringMatching(value: string | RegExp): Any;
interface Clock {
install(): void;
uninstall(): void;
/**
* Calls to any registered callback are triggered when the clock isticked forward
* via the jasmine.clock().tick function, which takes a number of milliseconds.
*/
tick(ms: number): void;
mockDate(date?: Date): void;
}
interface Any {
new (expectedClass: any): any;
jasmineMatches(other: any): boolean;
jasmineToString(): string;
}
interface ArrayContaining {
new (sample: any[]): any;
asymmetricMatch(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
}
interface Spy {
(...params: any[]): any;
identity: string;
and: SpyAnd;
calls: Calls;
mostRecentCall: { args: any[] };
argsForCall: any[];
wasCalled: boolean;
}
interface SpyAnd {
/**
* By chaining the spy with and.callThrough, the spy will still track all
* calls to it but in addition it will delegate to the actual implementation.
*/
callThrough(): Spy;
/**
* By chaining the spy with and.returnValue, all calls to the function
* will return a specific value.
*/
returnValue(val: any): Spy;
/**
* By chaining the spy with and.returnValues, all calls to the function
* will return specific values in order until it reaches the end of the return values list.
*/
returnValues(...values: any[]): Spy;
/**
* By chaining the spy with and.callFake, all calls to the spy
* will delegate to the supplied function.
*/
callFake(fn: (...args: any[]) => any): Spy;
/**
* By chaining the spy with and.throwError, all calls to the spy
* will throw the specified value.
*/
throwError(msg: string): Spy;
/**
* When a calling strategy is used for a spy, the original stubbing
* behavior can be returned at any time with and.stub.
*/
stub(): Spy;
}
interface Calls {
/**
* By chaining the spy with calls.any(),
* will return false if the spy has not been called at all,
* and then true once at least one call happens.
*/
any(): boolean;
/**
* By chaining the spy with calls.count(),
* will return the number of times the spy was called
*/
count(): number;
/**
* By chaining the spy with calls.argsFor(),
* will return the arguments passed to call number index
*/
argsFor(index: number): any[];
/**
* By chaining the spy with calls.allArgs(),
* will return the arguments to all calls
*/
allArgs(): any[];
/**
* By chaining the spy with calls.all(), will return the
* context (the this) and arguments passed all calls
*/
all(): CallInfo[];
/**
* By chaining the spy with calls.mostRecent(), will return the
* context (the this) and arguments for the most recent call
*/
mostRecent(): CallInfo;
/**
* By chaining the spy with calls.first(), will return the
* context (the this) and arguments for the first call
*/
first(): CallInfo;
/**
* By chaining the spy with calls.reset(), will clears all tracking for a spy
*/
reset(): void;
}
interface CallInfo {
/**
* The context (the this) for the call
*/
object: any;
/**
* All arguments passed to the call
*/
args: any[];
/**
* The return value of the call
*/
returnValue: any;
}
interface CustomMatcherFactories {
[index: string]: CustomMatcherFactory;
}
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher;
interface MatchersUtil {
equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean;
// tslint:disable-next-line: no-unnecessary-generics
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: CustomEqualityTester[]): boolean;
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
}
type CustomEqualityTester = (first: any, second: any) => boolean;
interface CustomMatcher {
compare<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
compare(actual: any, ...expected: any[]): CustomMatcherResult;
}
interface CustomMatcherResult {
pass: boolean;
message: string | (() => string);
}
interface ArrayLike<T> {
length: number;
[n: number]: T;
}
}
{
"name": "@types/jest",
"version": "26.0.23",
"description": "TypeScript definitions for Jest",
"license": "MIT",
"contributors": [
{
"name": "Asana (https://asana.com)\n// Ivo Stratev",
"url": "https://github.com/NoHomey",
"githubUsername": "NoHomey"
},
{
"name": "jwbay",
"url": "https://github.com/jwbay",
"githubUsername": "jwbay"
},
{
"name": "Alexey Svetliakov",
"url": "https://github.com/asvetliakov",
"githubUsername": "asvetliakov"
},
{
"name": "Alex Jover Morales",
"url": "https://github.com/alexjoverm",
"githubUsername": "alexjoverm"
},
{
"name": "Allan Lukwago",
"url": "https://github.com/epicallan",
"githubUsername": "epicallan"
},
{
"name": "Ika",
"url": "https://github.com/ikatyang",
"githubUsername": "ikatyang"
},
{
"name": "Waseem Dahman",
"url": "https://github.com/wsmd",
"githubUsername": "wsmd"
},
{
"name": "Jamie Mason",
"url": "https://github.com/JamieMason",
"githubUsername": "JamieMason"
},
{
"name": "Douglas Duteil",
"url": "https://github.com/douglasduteil",
"githubUsername": "douglasduteil"
},
{
"name": "Ahn",
"url": "https://github.com/ahnpnl",
"githubUsername": "ahnpnl"
},
{
"name": "Josh Goldberg",
"url": "https://github.com/joshuakgoldberg",
"githubUsername": "joshuakgoldberg"
},
{
"name": "Jeff Lau",
"url": "https://github.com/UselessPickles",
"githubUsername": "UselessPickles"
},
{
"name": "Andrew Makarov",
"url": "https://github.com/r3nya",
"githubUsername": "r3nya"
},
{
"name": "Martin Hochel",
"url": "https://github.com/hotell",
"githubUsername": "hotell"
},
{
"name": "Sebastian Sebald",
"url": "https://github.com/sebald",
"githubUsername": "sebald"
},
{
"name": "Andy",
"url": "https://github.com/andys8",
"githubUsername": "andys8"
},
{
"name": "Antoine Brault",
"url": "https://github.com/antoinebrault",
"githubUsername": "antoinebrault"
},
{
"name": "Gregor Stamać",
"url": "https://github.com/gstamac",
"githubUsername": "gstamac"
},
{
"name": "ExE Boss",
"url": "https://github.com/ExE-Boss",
"githubUsername": "ExE-Boss"
},
{
"name": "Alex Bolenok",
"url": "https://github.com/quassnoi",
"githubUsername": "quassnoi"
},
{
"name": "Mario Beltrán Alarcón",
"url": "https://github.com/Belco90",
"githubUsername": "Belco90"
},
{
"name": "Tony Hallett",
"url": "https://github.com/tonyhallett",
"githubUsername": "tonyhallett"
},
{
"name": "Jason Yu",
"url": "https://github.com/ycmjason",
"githubUsername": "ycmjason"
},
{
"name": "Devansh Jethmalani",
"url": "https://github.com/devanshj",
"githubUsername": "devanshj"
},
{
"name": "Pawel Fajfer",
"url": "https://github.com/pawfa",
"githubUsername": "pawfa"
},
{
"name": "Regev Brody",
"url": "https://github.com/regevbr",
"githubUsername": "regevbr"
},
{
"name": "Alexandre Germain",
"url": "https://github.com/gerkindev",
"githubUsername": "gerkindev"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/jest"
},
"scripts": {},
"dependencies": {
"jest-diff": "^26.0.0",
"pretty-format": "^26.0.0"
},
"typesPublisherContentHash": "2ba294369468924cf573f064d944f4d4df1a25e8b23a828c75a085ef2452f0c3",
"typeScriptVersion": "3.8"
}
\ No newline at end of file
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
# Installation
> `npm install --save @types/node`
# Summary
This package contains type definitions for Node.js (http://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Sun, 27 Jun 2021 03:01:14 GMT
* Dependencies: none
* Global values: `AbortController`, `AbortSignal`, `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Jason Kwok](https://github.com/JasonHK), [Victor Perin](https://github.com/victorperin), and [Yongsheng Zhang](https://github.com/ZYSzys).
declare module 'assert' {
/** An alias of `assert.ok()`. */
function assert(value: any, message?: string | Error): asserts value;
namespace assert {
class AssertionError extends Error {
actual: any;
expected: any;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
constructor(options?: {
/** If provided, the error message is set to this value. */
message?: string;
/** The `actual` property on the error instance. */
actual?: any;
/** The `expected` property on the error instance. */
expected?: any;
/** The `operator` property on the error instance. */
operator?: string;
/** If provided, the generated stack trace omits frames before this function. */
// tslint:disable-next-line:ban-types
stackStartFn?: Function;
});
}
class CallTracker {
calls(exact?: number): () => void;
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
report(): CallTrackerReportInformation[];
verify(): void;
}
interface CallTrackerReportInformation {
message: string;
/** The actual number of times the function was called. */
actual: number;
/** The number of times the function was expected to be called. */
expected: number;
/** The name of the function that is wrapped. */
operator: string;
/** A stack trace of the function. */
stack: object;
}
type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(
actual: any,
expected: any,
message?: string | Error,
operator?: string,
// tslint:disable-next-line:ban-types
stackStartFn?: Function,
): never;
function ok(value: any, message?: string | Error): asserts value;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function throws(block: () => any, message?: string | Error): void;
function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
function doesNotThrow(block: () => any, message?: string | Error): void;
function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
function ifError(value: any): asserts value is null | undefined;
function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function rejects(
block: (() => Promise<any>) | Promise<any>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(
block: (() => Promise<any>) | Promise<any>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
function match(value: string, regExp: RegExp, message?: string | Error): void;
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
const strict: Omit<
typeof assert,
| 'equal'
| 'notEqual'
| 'deepEqual'
| 'notDeepEqual'
| 'ok'
| 'strictEqual'
| 'deepStrictEqual'
| 'ifError'
| 'strict'
> & {
(value: any, message?: string | Error): asserts value;
equal: typeof strictEqual;
notEqual: typeof notStrictEqual;
deepEqual: typeof deepStrictEqual;
notDeepEqual: typeof notDeepStrictEqual;
// Mapped types and assertion functions are incompatible?
// TS2775: Assertions require every name in the call target
// to be declared with an explicit type annotation.
ok: typeof ok;
strictEqual: typeof strictEqual;
deepStrictEqual: typeof deepStrictEqual;
ifError: typeof ifError;
strict: typeof strict;
};
}
export = assert;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment