App to reproduce firebase/firebase-js-sdk#3096
- Clone this Git repository.
- Open a shell in the cloned directory.
npm install -g jest
npm install
firebase emulators:start --only firestore
jest test.js
The test will fail with the following error and hang:
FIRESTORE (7.14.3) INTERNAL ASSERTION FAILED: value must be undefined or Uint8Array
This internal assertion is unexpected and should not be happening.
To see the expected behavior, do the following:
git clean -dfx
rm package-lock.json
sed -i .bak 's/19.4/15.0/' package.json
npm install
firebase emulators:start --only firestore
jest test.js
The test will still fail, but with an appropriate message:
Expected request to fail, but it succeeded.
A workaround is documented in jestjs/jest#7780 and
it worked for me. Below are the instructions to apply the workaround. To see
the workaround, checkout the workaround
branch.
- Follow the instructions above to reproduce the issue.
npm i jest-environment-node
- Create a file named
__test-utils__/custom-jest-environment.js
and set its contents to https://github.com/dconeybe/FirebaseJsBug3096/blob/workaround/__test-utils__/custom-jest-environment.js. - Add the following to
package.json
:"jest": { "testEnvironment": "./__test-utils__/custom-jest-environment.js" }
jest test.js
The test will still fail, but with a failure not related to an internal error, which demonstrates that the bug was worked around successfully.