typescript - Hvordan enhetsteste firebase blokkeringsfunksjoner?
Jeg tester firebase-blokkeringsfunksjoner med firebase-functions-test, men det finnes ingen overbelastning på wrap-funksjonen
Produksjonskode:
export const beforeSignIn = auth.user().beforeSignIn(async (user, context) => {
if (user.phoneNumber == undefined) {
throw new HttpsError(
"permission-denied", "Invalid phone number");
}
return;
});
Testkode:
const wrapped = wrap(beforeSignIn);
Feilmelding sier:
No overload matches this call.
Overload 1 of 3, '(cloudFunction: HttpsFunction & Runnable<unknown>): WrappedFunction<unknown, HttpsFunction & Runnable<unknown>>', gave the following error.
Argument of type 'BlockingFunction' is not assignable to parameter of type 'HttpsFunction & Runnable<unknown>'.
Property 'run' is missing in type 'BlockingFunction' but required in type 'Runnable<unknown>'.
Overload 2 of 3, '(cloudFunction: CloudFunction<unknown>): WrappedScheduledFunction | WrappedFunction<unknown>', gave the following error.
Argument of type 'BlockingFunction' is not assignable to parameter of type 'CloudFunction<unknown>'.
Property 'run' is missing in type 'BlockingFunction' but required in type 'CloudFunction<unknown>'.
Overload 3 of 3, '(cloudFunction: CloudFunction<CloudEvent<unknown>>): WrappedV2Function<CloudEvent<unknown>>', gave the following error.
Argument of type 'BlockingFunction' is not assignable to parameter of type 'CloudFunction<CloudEvent<unknown>>'.
Property 'run' is missing in type 'BlockingFunction' but required in type 'CloudFunction<CloudEvent<unknown>>'.t
Funksjonen wrap aksepterer ikke typen BlockingFunction, og hvordan teste det ved å bruke firebase-functions-test?