Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Trying to test firebase rules with emulator

I'm trying to setup my testEnvironment for testing my firestore rules with my locally running emulator.

When i try to access testEnv it is undefined, and I guess that has something to do with initializeTestEnvironment being asynchronous, but how do I get around that?

import {
    assertFails,
    assertSucceeds,
    initializeTestEnvironment,
    RulesTestEnvironment,

  } from "@firebase/rules-unit-testing"

import fs from 'fs'

const projectId = 'comment-section-e9c09';

let testEnv:RulesTestEnvironment;

beforeAll( async () => {
  let testEnv = await initializeTestEnvironment({
    projectId: projectId,
    firestore: {
      rules: fs.readFileSync("firestore.rules", "utf8"),
      host:'localhost',
      port:8080
    },
  });
})

test("should clear db",() => {
  testEnv.clearDatabase()
})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!