firebase / firebase/quickstart-testing

Problem testing with `firebase.firestore.FieldValue.serverTimestamp()`

オープン
#191 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
368
フォーク
125
PR マージ指標
30日以内にマージされた PR はありません

説明

I migrated over from `@firebase/testing` to `@firebase/rules-unit-testing` and now all of my tests that use `firebase.firestore.FieldValue.serverTimestamp()` are failing.

```
Articles collection
Should allow an admin to update an article:
Error: Value for argument "data" is not a valid Firestore document. Detected an object of type "FieldValue" that doesn't match the expected instance (found in field "created_at"). Please ensure that the Firestore types you are using are from the same NPM package.)
at validateUserInput (node_modules/@google-cloud/firestore/build/src/serializer.js:332:15)
at Object.validateUserInput (node_modules/@google-cloud/firestore/build/src/serializer.js:269:13)
at validateDocumentData (node_modules/@google-cloud/firestore/build/src/write-batch.js:588:18)
at WriteBatch.set (node_modules/@google-cloud/firestore/build/src/write-batch.js:247:9)
at Transaction.set (node_modules/@google-cloud/firestore/build/src/transaction.js:178:26)
at /Users/victoruvarov/work/tive/tive-backend/test/articles_collection.spec.js:216:19
at Transaction.runTransaction (node_modules/@google-cloud/firestore/build/src/transaction.js:333:33)
at async Context. (test/articles_collection.spec.js:215:5)
```

imports

```javaScript
const firebase = require("@firebase/rules-unit-testing");
const fs = require("fs");
const http = require("http");
```

dependencies

```json
"devDependencies": {
"@firebase/rules-unit-testing": "^1.3.13",
"firebase-admin": "^9.11.0",
"firebase-tools": "^9.16.0",
"mocha": "^8.4.0"
}
```

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

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

調査の方向性

test/articles_collection.spec.js の 215〜216 行付近から始め、firebase.firestore.FieldValue.serverTimestamp() を使用して失敗するトランザクションを再現します。記載されている @firebase/rules-unit-testing と firebase-admin の依存関係を確認し、互換性のない Firestore 型がないか調べます。影響を受けるテストが無効な FieldValue エラーなしで serverTimestamp の値を受け入れれば完了です。

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

評価

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

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

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