soumak77 / firebase-mock

Firebase mock library for writing unit tests
https://soumak77.github.io/firebase-mock
350 stars 96 forks source link

Cannot read property replace of undefined when path is '/' #97

Closed SidneyNemzer closed 6 years ago

SidneyNemzer commented 6 years ago
const firebaseMock = require("firebase-mock")

const mockdatabase = new firebaseMock.MockFirebase()
mockdatabase.child('/') //=> TypeError

Runkit

Stacktrace:

TypeError "Cannot read property 'replace' of undefined"
  at Object.mergePaths (node_modules/firebase-mock/src/utils.js:12:46)
  at MockFirebase.child (node_modules/firebase-mock/src/firebase.js:154:36)

Firebase JS SDK behavior:

firebase.database().ref('/') //=> Reference
firebase.database().ref('/').child('/') //=> Reference

(Both reference the same path, "/")