-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore (v9): Cannot pass compat firestore to modular functions runTransaction and writeBatch #5627
Comments
FWIW, the braces for the - (await initializeTestEnvironment(projectId).unauthenticatedContext()).firestore();
+ (await initializeTestEnvironment(projectId)).unauthenticatedContext().firestore(); // <-- should be like this
|
That`s indeed a typo in the issue description :( |
The relevant code to reproduce this issue is: import { initializeTestEnvironment } from "@firebase/rules-unit-testing";
import { runTransaction } from "firebase/firestore";
const firestore = (await initializeTestEnvironment({
projectId: "demo-test"
})).unauthenticatedContext().firestore();
runTransaction(firestore as any,
() => Promise.resolve()
); or wrapped in a jest test test suite: import { initializeTestEnvironment } from "@firebase/rules-unit-testing";
import { runTransaction } from "firebase/firestore";
describe("runTransaction", () => {
it("should not throw an error", async () => {
const firestore = (await initializeTestEnvironment({
projectId: "demo-test"
})).unauthenticatedContext().firestore();
expect(
runTransaction(firestore as any,
() => Promise.resolve()
)
).not.toThrow();
});
}); |
Hey, thanks for report this bug, I have put in a fix that should make this go away! |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
If I understand the comment from issue #5550 correctly...
..., but you can pass it to any function exported from the modular SDK where a modular Firestore is accepted, such as
ref()
.Originally posted by @Feiyang1 in #5550 (comment)
..., then the firestore object created with:
should be allowed to pass to modular firestore functions such as
ref()
but also(?)collection()
,doc()
, ... andrunTransaction()
?However, when passing that firestore object to
runTransaction
it throws the following error:The text was updated successfully, but these errors were encountered: