firebase / firebase/firebase-admin-node

'@firebase/database-compat/standalone' import error in jest tests

オープン
#2,091 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
api: database
主要言語
TypeScript
スター
1.7k
フォーク
419
平均マージ
3日 10時間
マージ済み PR(30日)
16

説明

Environment

* Operating System version: MacOS 12.6.3
* Firebase SDK version: 11.3.0
* Firebase Product: firebase-admin
* Node.js version: 16.19.0
* NPM version: 8.19.3
* jest: 29.4.3
* typescript: 4.9.3

Describe the problem
After updating:
`firebase-functions` v3 -> v4
`firebase-admin` v11.3 -> v11.5
`firebase-functions-test` v0.3.0 -> v3.0.0

Any jest test using any firebase library will fail with the following error:
```
● Test suite failed to run

Cannot find module '@firebase/database-compat/standalone' from '../../node_modules/firebase-admin/lib/database/index.js'

Require stack:
/Users/igor/Dev/vogel_database/node_modules/firebase-admin/lib/database/index.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/common/providers/database.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/v1/providers/database.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions/lib/v1/index.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/v1.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/main.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/features.js
/Users/igor/Dev/vogel_database/node_modules/firebase-functions-test/lib/index.js
path/to/the/test/file.test.ts
```

Call stack in the example above may differ depending on the firebase library used, but will alway end at `Users/igor/Dev/vogel_database/node_modules/firebase-admin/lib/database/index.js` with the same error for importing `'@firebase/database-compat/standalone'`.

#### Steps to reproduce:

Install libraries with the provided versions.
Run `jest ` where test file uses at least one firebase library that has an internal reference to `firebase-admin`.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Reproduce the failure with the listed firebase-functions, firebase-admin, firebase-functions-test, Node.js, and Jest versions. Start at firebase-admin/lib/database/index.js and trace the dependency resolution for '@firebase/database-compat/standalone'; done means a Jest test importing a Firebase library starts without this module error.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
node.js, typescript
領域
backend, testing
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。