UNPKG

3.11 kBTypeScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7/// <reference types="node" />
8import type { AssertionError } from 'assert';
9import type { Config } from '@jest/types';
10import expect = require('expect');
11import type CallTracker from './jasmine/CallTracker';
12import type Env from './jasmine/Env';
13import type JsApiReporter from './jasmine/JsApiReporter';
14import type ReportDispatcher from './jasmine/ReportDispatcher';
15import type { default as Spec, SpecResult } from './jasmine/Spec';
16import type SpyStrategy from './jasmine/SpyStrategy';
17import type { default as Suite, SuiteResult } from './jasmine/Suite';
18import type Timer from './jasmine/Timer';
19import type createSpy from './jasmine/createSpy';
20import type SpyRegistry from './jasmine/spyRegistry';
21export declare type SpecDefinitionsFn = () => void;
22export interface AssertionErrorWithStack extends AssertionError {
23 stack: string;
24}
25export declare type SyncExpectationResult = {
26 pass: boolean;
27 message: () => string;
28};
29export declare type AsyncExpectationResult = Promise<SyncExpectationResult>;
30export declare type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
31export declare type RawMatcherFn = (expected: unknown, actual: unknown, options?: unknown) => ExpectationResult;
32export declare type RunDetails = {
33 totalSpecsDefined?: number;
34 failedExpectations?: SuiteResult['failedExpectations'];
35};
36export declare type Reporter = {
37 jasmineDone: (runDetails: RunDetails) => void;
38 jasmineStarted: (runDetails: RunDetails) => void;
39 specDone: (result: SpecResult) => void;
40 specStarted: (spec: SpecResult) => void;
41 suiteDone: (result: SuiteResult) => void;
42 suiteStarted: (result: SuiteResult) => void;
43};
44export interface Spy extends Record<string, any> {
45 (this: Record<string, unknown>, ...args: Array<any>): unknown;
46 and: SpyStrategy;
47 calls: CallTracker;
48 restoreObjectToOriginalState?: () => void;
49}
50declare type JasmineMatcher = {
51 (matchersUtil: unknown, context: unknown): JasmineMatcher;
52 compare: () => RawMatcherFn;
53 negativeCompare: () => RawMatcherFn;
54};
55export declare type JasmineMatchersObject = {
56 [id: string]: JasmineMatcher;
57};
58export declare type Jasmine = {
59 _DEFAULT_TIMEOUT_INTERVAL: number;
60 DEFAULT_TIMEOUT_INTERVAL: number;
61 currentEnv_: ReturnType<typeof Env>['prototype'];
62 getEnv: () => ReturnType<typeof Env>['prototype'];
63 createSpy: typeof createSpy;
64 Env: ReturnType<typeof Env>;
65 JsApiReporter: typeof JsApiReporter;
66 ReportDispatcher: typeof ReportDispatcher;
67 Spec: typeof Spec;
68 SpyRegistry: typeof SpyRegistry;
69 Suite: typeof Suite;
70 Timer: typeof Timer;
71 version: string;
72 testPath: Config.Path;
73 addMatchers: (matchers: JasmineMatchersObject) => void;
74} & typeof expect & typeof globalThis;
75declare global {
76 namespace NodeJS {
77 interface Global {
78 expect: typeof expect;
79 }
80 }
81}
82export {};