Skip to content

Params not created from refPath #10

@ahaverty

Description

@ahaverty

Version info

firebase-functions-test: v0.1.1
firebase-functions: v1.0.1
firebase-admin: v5.12.0

Steps to reproduce

let data = test.database.makeDataSnapshot({ valProp1: "hello", valProp2: 12345 }, "my/path/param1/param2"); await test.wrap(myFunctions.func1)(data);

Expected behavior

export let func1 = functions.database.ref('my/path/{param1}/{param2}').onCreate(async (snapshot, context) => { let param1: string = context.params.param1; //"param1" let param2: string = context.params.param2; //"param2" let val1: string = snapshot.val().val1; //"hello" let val2: number = snapshot.val().val2; //12345 )};

Actual behavior

export let func1 = functions.database.ref('my/path/{param1}/{param2}').onCreate(async (snapshot, context) => { let param1: string = context.params.param1; //undefined let param2: string = context.params.param2; //undefined let val1: string = snapshot.val().val1; //"hello" let val2: number = snapshot.val().val2; //12345 )};

Workaround

let data = test.database.makeDataSnapshot({ valProp1: "hello", valProp2: 12345 }, "my/path/param1/param2"); await test.wrap(myFunctions.func1)(data, { params: { param1: userId, param2: orderId } });

It took a few debugging attempts to discover that the pathRef wasn't auto parsing into the context's params without the options in wrap().
Re-reading the docs, it looks like this is by design and similar to what firebase functions:shell was doing
However, If it's possible to automatically parse the refPath into context, please take this as a feature request 🙇.
Perhaps the docs could highlight that parsing params into context isn't a thing? 🤔

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions