Skip to content

@firebase/component is missing from dependencies of @firebase/rules-unit-testing, breaking Yarn Plug'n'Play #4716

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

Closed
ti1024 opened this issue Apr 2, 2021 · 0 comments · Fixed by #4717
Labels
testing-sdk testing with emulator

Comments

@ti1024
Copy link
Contributor

ti1024 commented Apr 2, 2021

[REQUIRED] Describe your environment

  • Operating System version: Ubuntu 20.10
  • Browser version: n/a
  • Firebase SDK version: @firebase/[email protected]
  • Firebase Product: firestore

[REQUIRED] Describe the problem

@firebase/rules-unit-testing depends on @firebase/component at this code:

import { Component, ComponentType } from '@firebase/component';

but the package.json of the former does not list the latter in the dependencies section. This makes it difficult to use the former with Yarn 2 Plug'n'Play. See https://yarnpkg.com/advanced/rulebook#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies for details of the restrictions Yarn 2 Plug'n'Play puts.

Steps to reproduce:

Set up Yarn 2 with the default settings, which enable Plug'n'Play:

$ mkdir firebase-testcase
$ cd firebase-testcase
$ cat > package.json
{
  "name": "firebase-testcase",
  "private": true
}
^D
$ yarn set version berry

Install @firebase/rules-unit-testing and jest:

$ yarn add -D @firebase/rules-unit-testing jest

Create a dummy test file:

$ cat > test.js
const testFirebase = require("@firebase/rules-unit-testing");
test('Do nothing', () => {});
^D

Run the test:

$ yarn jest

This results in an error:

    @firebase/rules-unit-testing tried to access @firebase/component, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

    Required package: @firebase/component (via "@firebase/component")
    Required by: @firebase/rules-unit-testing@virtual:1d9273e5f68268c40e08b7f99e80cf4710c78cbaac3826d945414a5b397a0f5f22b53cc2698d26ce2c1e26bf0fc5d219aa5f31558a8fde3204ffebed140e1f69#npm:1.2.6 (via /tmp/firebase-testcase/.yarn/$$virtual/@firebase-rules-unit-testing-virtual-083cacfd56/0/cache/@firebase-rules-unit-testing-npm-1.2.6-b87f90698b-2f74f80241.zip/node_modules/@firebase/rules-unit-testing/dist/)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
testing-sdk testing with emulator
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants