File tree Expand file tree Collapse file tree 2 files changed +9
-34
lines changed
packages/rules-unit-testing Expand file tree Collapse file tree 2 files changed +9
-34
lines changed Original file line number Diff line number Diff line change @@ -88,25 +88,16 @@ export function getEmulatorHostAndPort(
8888 discovered ?: DiscoveredEmulators
8989) {
9090 if ( conf && 'host' in conf && 'port' in conf ) {
91- const { host, port } = conf ;
92- if ( host || port ) {
93- if ( ! host || ! port ) {
94- throw new Error (
95- `Invalid configuration ${ emulator } .host=${ host } and ${ emulator } .port=${ port } . ` +
96- 'If either parameter is supplied, both must be defined.'
97- ) ;
98- }
99- if ( discovered && ! discovered [ emulator ] ) {
100- console . warn (
101- `Warning: config for the ${ emulator } emulator is specified, but the Emulator hub ` +
102- 'reports it as not running. This may lead to errors such as connection refused.'
103- ) ;
104- }
105- return {
106- host : fixHostname ( conf . host , discovered ?. hub ?. host ) ,
107- port : conf . port
108- } ;
91+ if ( discovered && ! discovered [ emulator ] ) {
92+ console . warn (
93+ `Warning: config for the ${ emulator } emulator is specified, but the Emulator hub ` +
94+ 'reports it as not running. This may lead to errors such as connection refused.'
95+ ) ;
10996 }
97+ return {
98+ host : fixHostname ( conf . host , discovered ?. hub ?. host ) ,
99+ port : conf . port
100+ } ;
110101 }
111102 const envVar = EMULATOR_HOST_ENV_VARS [ emulator ] ;
112103 const fallback = discovered ?. [ emulator ] || emulatorFromEnvVar ( envVar ) ;
Original file line number Diff line number Diff line change @@ -123,22 +123,6 @@ describe('getEmulatorHostAndPort()', () => {
123123 expect ( result ?. host ) . to . equal ( '::1' ) ;
124124 } ) ;
125125
126- it ( 'throws if only host is present' , async ( ) => {
127- expect ( ( ) =>
128- getEmulatorHostAndPort ( 'hub' , {
129- host : '[::1]'
130- } as HostAndPort )
131- ) . to . throw ( / h u b .p o r t = u n d e f i n e d / ) ;
132- } ) ;
133-
134- it ( 'throws if only port is present' , async ( ) => {
135- expect ( ( ) =>
136- getEmulatorHostAndPort ( 'database' , {
137- port : 1234
138- } as HostAndPort )
139- ) . to . throw ( / I n v a l i d c o n f i g u r a t i o n d a t a b a s e .h o s t = u n d e f i n e d / ) ;
140- } ) ;
141-
142126 it ( 'connect to 127.0.0.1 if host is wildcard 0.0.0.0' , async ( ) => {
143127 const result = getEmulatorHostAndPort ( 'hub' , {
144128 host : '0.0.0.0' ,
You can’t perform that action at this time.
0 commit comments