Skip to content

SyntaxError: The requested module '@firebase/rules-unit-testing' does not provide an export named 'RulesTestEnvironment'. #7987

@asaadjaber

Description

@asaadjaber

Operating System

MacOS 14.3.

Browser Version

Firefox/122.0.

Firebase SDK Version

13.0.3

Firebase SDK Product:

Firestore

Describe your project's tooling

iOS app with Mocha v10.2.0 and node v20.9.0.

Describe the problem

I was trying to run a unit test locally to test writes to my database which is in Cloud Firestore. I wrote a test which I called 'test.js' that imports RulesTestEnvironment from the @firebase/rules-unit-testing module. The test uses an import from @firebase/rules-unit testing and another from "firebase/firestore".

import {
  assertFails,
  assertSucceeds,
  initializeTestEnvironment,
  RulesTestEnvironment,
} from "@firebase/rules-unit-testing"

When I tried to run the unit test from the command line, I ran into an error that said 'SyntaxError: The requested module '@firebase/rules-unit-testing' does not provide an export named 'RulesTestEnvironment'.

The error that appeared:
Screenshot 2024-01-29 at 12 20 02

Steps and code to reproduce issue

After I started the emulator, I ran the test in this file https://github.com/asaadjaber/special-parakeet-fork/blob/cloud-firestore-unit-tests-using-mocha/Special%20Parakeet/test/test.js from the command line using npm test and I encountered the error saying 'SyntaxError: The requested module '@firebase/rules-unit-testing' does not provide an export named 'RulesTestEnvironment'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions