Skip to content

Commit e6f2fd4

Browse files
committed
test(functions): use local timeout function for tests
previous timeout function appeared to use network which caused problems with iOS insecure network loads
1 parent 788cc22 commit e6f2fd4

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

.github/workflows/scripts/functions/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ export const helloWorld = functions.https.onRequest((request, response) => {
88
response.send('{ "data": "Hello from Firebase!" }');
99
});
1010

11+
export const sleeper = functions.https.onCall(async data => {
12+
functions.logger.info('Sleeper function starting');
13+
return await new Promise(() =>
14+
setTimeout(() => functions.logger.info('done sleeping'), data?.delay ?? 3000),
15+
);
16+
});
17+
1118
export { testFunctionCustomRegion } from './testFunctionCustomRegion';
1219
export { testFunctionDefaultRegion } from './testFunctionDefaultRegion';
1320
export { testFunctionRemoteConfigUpdate } from './testFunctionRemoteConfigUpdate';

packages/functions/e2e/functions.e2e.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,9 @@ describe('functions() modular', function () {
317317
});
318318

319319
it('HttpsCallableOptions.timeout will error when timeout is exceeded', async function () {
320-
const fnName = 'invertaseReactNativeFirebaseFunctionsEmulator';
321-
const region = 'europe-west2';
322-
323-
const functions = firebase.app().functions(region);
324-
functions.useFunctionsEmulator('http://api.rnfirebase.io');
325-
320+
const functionRunner = firebase.functions().httpsCallable('sleeper', { timeout: 1000 });
326321
try {
327-
await functions.httpsCallable(fnName, { timeout: 1000 })({ testTimeout: '3000' });
322+
await functionRunner({ delay: 3000 });
328323
return Promise.reject(new Error('Did not throw an Error.'));
329324
} catch (error) {
330325
error.message.should.containEql('DEADLINE').containEql('EXCEEDED');
@@ -697,15 +692,12 @@ describe('functions() modular', function () {
697692
});
698693

699694
it('HttpsCallableOptions.timeout will error when timeout is exceeded', async function () {
700-
const { getFunctions, httpsCallable, connectFunctionsEmulator } = functionsModular;
701-
const fnName = 'invertaseReactNativeFirebaseFunctionsEmulator';
702-
const region = 'europe-west2';
703-
704-
const functions = getFunctions(firebase.app(), region);
705-
connectFunctionsEmulator(functions, 'api.rnfirebase.io', 5001);
695+
const { getFunctions, httpsCallable } = functionsModular;
696+
const functions = getFunctions(firebase.app());
697+
const functionRunner = httpsCallable(functions, 'sleeper', { timeout: 1000 });
706698

707699
try {
708-
await httpsCallable(functions, fnName, { timeout: 1000 })({ testTimeout: '3000' });
700+
await functionRunner({ delay: 3000 });
709701
return Promise.reject(new Error('Did not throw an Error.'));
710702
} catch (error) {
711703
error.message.should.containEql('DEADLINE').containEql('EXCEEDED');

0 commit comments

Comments
 (0)