针对 Firebase 模拟器进行测试时出错“预期类型‘Pa’,但它是:自定义 Fa 对象”

skm*_*lin 6 javascript firebase-tools cypress google-cloud-firestore

我目前正在尝试在赛普拉斯中执行以下测试。

before(async () => {
  testEnv = await initializeTestEnvironment({
    projectId: MY_PROJECT_ID,
    firestore: {
      host: "localhost",
      port: 8080,
    },
  });
});
describe("Authorized user can write to collection", () => {
  it("Can write to firestore doc", async () => {
    console.log("testEnv", testEnv);

    const alice = testEnv.authenticatedContext("alice", { role: "user" });
    console.log("alice", alice);

    const firestore = alice.firestore();
    console.log("firestore", firestore);

    const testA = await assertSucceeds(
      setDoc(alice.firestore(), "/users/alice"),
      {
        foo: "bar",
      }
    );
    console.log("testA", testA);
  });
});
Run Code Online (Sandbox Code Playgroud)

在 setDoc 调用期间,测试在最终 console.log 之前失败。错误是

Expected type 'Pa', but it was: a custom Fa object
Run Code Online (Sandbox Code Playgroud)

我相信我将此自定义 Fa 对象跟踪到了 firestore 变量上的 _delegate 属性,但我不清楚如何从这里继续。

  • 我在运行之前确保模拟器都在运行npx cypress open
  • 我尝试通过集线器设置 firestore 属性并得到相同的结果
  • 我还尝试将“规则”属性作为字符串传递给 firestore

任何帮助将不胜感激!