forked from mongodb/node-mongodb-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.d.ts
More file actions
129 lines (113 loc) · 4.43 KB
/
global.d.ts
File metadata and controls
129 lines (113 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { type OneOrMore } from './src/mongo_types';
import type { TestConfiguration } from './test/tools/runner/config';
declare global {
interface MongoDBMetadataUI {
requires?: {
topology?: TopologyTypeRequirement;
mongodb?: string;
os?: NodeJS.Platform | `!${NodeJS.Platform}`;
apiVersion?: '1' | boolean;
/**
* require FLE to be set up to run the test
*
* A semver range may be provided as well to enforce a particular version range
* of mongodb-client-encryption. Ex: `clientSideEncryption: '>=6.0.1'`
*/
clientSideEncryption?: string | true;
auth?: 'enabled' | 'disabled';
idmsMockServer?: true;
nodejs?: string;
predicate?: (test?: Mocha.Test) => true | string;
crypt_shared?: 'enabled' | 'disabled',
libmongocrypt?: string;
};
sessions?: {
skipLeakTests?: boolean;
};
}
type WithExclusion<T extends string> = `!${T}`;
/** Defined in test/tools/runner/filters/mongodb_topology_filter.js (topologyTypeToString) */
type TopologyTypes = 'single' | 'replicaset' | 'sharded' | 'load-balanced';
type TopologyTypeRequirement = OneOrMore<TopologyTypes> | OneOrMore<WithExclusion<TopologyTypes>>;
interface MetadataAndTest<Fn> {
metadata: MongoDBMetadataUI;
test: Fn;
}
namespace Chai {
interface Assertion {
/** @deprecated Used only by the legacy spec runner, the unified runner implements the unified spec expectations */
matchMongoSpec: (anything: any) => Chai.Assertion;
}
}
namespace Mocha {
interface SuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: (this: Suite) => void): Mocha.Suite;
}
interface PendingSuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: (this: Suite) => void): Mocha.Suite;
}
interface ExclusiveSuiteFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface ExclusiveTestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface TestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface PendingTestFunction {
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.AsyncFunc): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.Func>): Mocha.Test;
(title: string, metadataAndTest: MetadataAndTest<Mocha.AsyncFunc>): Mocha.Test;
}
interface Context {
configuration: TestConfiguration;
/** @deprecated Please use afterEach hooks instead */
defer(fn: () => Promise<unknown>): void;
}
interface Test {
metadata: MongoDBMetadataUI;
spec: Record<string, any>;
}
interface Runnable {
/**
* An optional string the test author can attach to print out why a test is skipped
*
* @example
* ```ts
* it.skip('my test', () => {
* //...
* }).skipReason = 'TODO(NODE-XXXX): Feature implementation impending!';
* ```
*
* The reporter (`test/tools/reporter/mongodb_reporter.js`) will print out the skipReason
* indented directly below the test name.
* ```txt
* - my test
* - TODO(NODE-XXXX): Feature implementation impending!
* ```
*
* You can also skip a set of tests via beforeEach:
* ```ts
* beforeEach(() => {
* if ('some condition') {
* this.currentTest.skipReason = 'requires <run condition> to run';
* this.skip();
* }
* });
* ```
*/
skipReason?: string;
}
}
}