Using the local emulator, I'm trying to test a rule for my delete & update which looks like this:
match /posts/{postId} {
allow read: if true;
allow create: if true;
allow delete, update: if (resource.data.user.uid == request.auth.uid)
}
In my test file, I write the path of the exact location of the existing doc that I'm trying to perform for example a delete on:
it("If creator, Allow delete/update items in the post/comment collection", async () => {
const db = firebase
.initializeTestApp({ projectId: MY_PROJECT_ID, auth: myAuth })
.firestore();
const testDoc = db
.collection("general")
.doc("spaces")
.collection("spaces")
.doc("9LbUetZxWeL1ln5hv9ug")
.collection("posts")
.doc("RtUnezdAgXUfWmRSPpkF");
await firebase.assertSucceeds(testDoc.delete());
});
However when I run this test, it gives me this error. However, I know this doc exists and so does the user.uid I am looking to grab in my resource. Is there something wrong in how I'm trying to use this emulator?
I also saw that if I go into my local emulator firestore database, I can hard-code a file, specifically call route my test to it, then it works.

It looks like no user is signed in when you run the test.
Since your security rules check request.auth.uid, they reject the operation when request.auth is null. Check myAuth.currentUser.uid before running the test to ensure it has a value.