@@ -99,7 +99,7 @@ export interface TestEnvironmentConfig {
99
99
* If specified either way, other running emulators can be automatically discovered, and thus do
100
100
* not to be explicity specified.
101
101
*/
102
- hub ?: Pick < EmulatorConfig , 'host' | 'port' > ;
102
+ hub ?: HostAndPort ;
103
103
104
104
/**
105
105
* The Database emulator. Its host and port can also be discovered automatically through the hub
@@ -121,26 +121,32 @@ export interface TestEnvironmentConfig {
121
121
}
122
122
123
123
/**
124
- * Configuration for a given emulator.
124
+ * An object containing the hostname and port number of an emulator.
125
125
* @public
126
126
*/
127
- export interface EmulatorConfig {
128
- /** The security rules source code under test for this emulator. Strongly recommended. */
129
- rules ?: string ;
130
-
127
+ export interface HostAndPort {
131
128
/**
132
129
* The host of the emulator. Can be omitted if discovered automatically through the hub or
133
130
* specified via environment variables. See {@code TestEnvironmentConfig} for details.
134
131
*/
135
- host ? : string ;
132
+ host : string ;
136
133
137
134
/**
138
135
* The port of the emulator. Can be omitted if discovered automatically through the hub or
139
136
* specified via environment variables. See {@code TestEnvironmentConfig} for details.
140
137
*/
141
- port ? : number ;
138
+ port : number ;
142
139
}
143
140
141
+ /**
142
+ * Configuration for a given emulator.
143
+ * @public
144
+ */
145
+ export type EmulatorConfig = {
146
+ /** The security rules source code under test for this emulator. Strongly recommended. */
147
+ rules ?: string ;
148
+ } & ( HostAndPort | { } ) ; // Both or none of host and port should be specified.
149
+
144
150
/**
145
151
* An object used to control the rules unit test environment. Can be used to create RulesTestContext
146
152
* for different authentication situations.
@@ -154,9 +160,9 @@ export interface RulesTestEnvironment {
154
160
* A readonly copy of the emulator config specified or discovered at test environment creation.
155
161
*/
156
162
readonly emulators : {
157
- database ?: { host : string ; port : number } ;
158
- firestore ?: { host : string ; port : number } ;
159
- storage ?: { host : string ; port : number } ;
163
+ database ?: HostAndPort ;
164
+ firestore ?: HostAndPort ;
165
+ storage ?: HostAndPort ;
160
166
} ;
161
167
162
168
/**
0 commit comments