Running Firestore local e.g. for testing

前端 未结 7 923
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:36

Is there a way to run firestore locally (e.g. for testing purposes)?

What would the approach to write tests against the DB (except of using mocks)

7条回答
  •  闹比i
    闹比i (楼主)
    2021-02-02 08:27

    for a firestore testing write a js example test.js you could test write with this format example

    var data = {
            value: {createTime: new Date(),
                    updateTime: new Date(),
                    fields:{
    
                            name:{stringValue:'new value data'},
                            age:{integerValue:50}
                          }
            },
            oldValue: {createTime: new Date(),  //old create time
                    updateTime: new Date(),  //old update time time
                    fields:{
    
                            name:{stringValue:'olvalue data'},
                            age:{integerValue:50}
                          }
            }
          };
    testFireStoreEvent(data);
    

    for run execute

    firebase experimental:functions:shell < test.js
    

    UPDATE!!!! VALID FOR WRITE AND UPDATE EVENTS

    var data = {
        before: {  
              //your before data
    
        },
        after: {
    
            //your after data
         }
      };
    testFireStoreEvent(data);
    

提交回复
热议问题