/FirebaseJsBug3096

App to reproduce https://github.com/firebase/firebase-js-sdk/issues/3096

Primary LanguageJavaScriptApache License 2.0Apache-2.0

FirebaseJsBug3096

App to reproduce firebase/firebase-js-sdk#3096

Instructions - Buggy Behavior

  1. Clone this Git repository.
  2. Open a shell in the cloned directory.
  3. npm install -g jest
  4. npm install
  5. firebase emulators:start --only firestore
  6. 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.

Instructions - Expected Behavior

To see the expected behavior, do the following:

  1. git clean -dfx
  2. rm package-lock.json
  3. sed -i .bak 's/19.4/15.0/' package.json
  4. npm install
  5. firebase emulators:start --only firestore
  6. jest test.js

The test will still fail, but with an appropriate message:

Expected request to fail, but it succeeded.

Workaround

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.

  1. Follow the instructions above to reproduce the issue.
  2. npm i jest-environment-node
  3. 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.
  4. Add the following to package.json:
    "jest": {
      "testEnvironment": "./__test-utils__/custom-jest-environment.js"
    }
    
  5. 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.