0
votes

I'm exploring Cloud Shell emulator for firebase security rules and in the tutorial I'm getting the below error on npm --prefix=functions test (step 4.5 of the tutorial, here is the link to the tutorial in case it's publicly accessible):

functions@ test /home/user/rules-tutorial/quickstart-testing/cs-walkthrough/functions

mocha --timeout 5000

body {"error":{"code":400,"message":"Payload isn't valid for request.","status":"INVALID_ARGUMENT"}}

0 passing (40ms)

1 failing

  1. "before all" hook in "{root}":

    Payload isn't valid for request.

How do I fix that?

1

1 Answers

2
votes

I had the same error.

Go to: rules-tutorial/quickstart-testing/cs-walkthrough/functions/test.js

Find this line and explicitly specify the encoding type:

  const rulesContent = fs.readFileSync(path.resolve(__dirname, "../firestore.rules"));

like this:

  const rulesContent = fs.readFileSync(path.resolve(__dirname, "../firestore.rules"), 'utf-8');

I hope the GCloud team will fix it in a future release.

enter image description here