App to reproduce firebase/firebase-js-sdk#3096
- Clone this Git repository.
- Open a shell in the cloned directory.
npm install -g jestnpm installfirebase emulators:start --only firestorejest 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 -dfxrm package-lock.jsonsed -i .bak 's/19.4/15.0/' package.jsonnpm installfirebase emulators:start --only firestorejest 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.jsand 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.