It turns out I needed to first install Java. Here is the final snippet that worked:
- name: gcr.io/cloud-builders/npm
entrypoint: bash
dir: edcloud/cloud-function/${_PROJECT_NAME}
args:
- -c
- |
apt-get update && apt-get install -y openjdk-11-jdk
npm install -g firebase-tools
npm install
firebase emulators:exec --project $PROJECT_ID 'npm test'