【发布时间】:2018-12-08 00:28:26
【问题描述】:
我使用 jest 在我的 Create React App 上运行一些测试,使用 Firebase Web SDK 和 FirebaseUI
每当我尝试使用 --env=jsdom 运行一些测试时,我都会遇到:
The current environment does not support the specified persistence type. 似乎与 Auth 相关
是否有任何已知的相关问题/解决方法?除了测试之外,代码似乎可以正常工作/编译。
Google 帮不上什么忙
这是测试,非常基础。
不得不添加import "firebase/storage";,因为这个:firebase.storage() is not a function in jest test cases
提前致谢
import React from "react";
import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import "firebase/storage";
import {filterIngredientsToRemove} from "./shoppingList-reducer";
Enzyme.configure({adapter: new Adapter()});
describe("", () => {
let shoppingList;
let recipeId;
beforeEach(() => {
shoppingList = {
shoppingListItems: {
"1234": {ingredientId: 987, name: "patate", recipeId: 1234},
"2345": {ingredientId: 987, name: "patate", recipeId: 5432}
},
shoppingListRecipes: {
"1234": {portion: 3}
}
};
recipeId = 1234;
});
it("should filter out the shoppinglistItems with the provided recipeId", () => {
const result = filterIngredientsToRemove(recipeId, shoppingList.shoppingListItems);
expect(result).toEqual([{ingredientId: 987, name: "patate", recipeId: 1234}]);
});
});
【问题讨论】:
-
关于这个问题的任何更新?我也遇到了同样的事情。
标签: firebase jestjs firebaseui