prev Kozaneba開発日記
今日の一枚
Cypress環境でGoogleが「このブラウザは安全ではないのでログインさせませーん」と言ってくることがわかった、これは…どうするのがいいのか…
ログインできるとこうなる
https://github.com/prescottprue/cypress-firebase
Error Your API key is invalid, please check you have copied it correctly. 手軽にできるかと思ったが情報量の少ないエラーにぶつかってしまった
たぶんLocal Emulator Suiteを構成してローカルのサーバで認証を行うのが良さそう https://firebase.google.com/docs/emulator-suite/install_and_configure?hl=ja
2021-08-04
$ firebase init emulators
:
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Use an existing project
Error: Failed to list Firebase projects. See firebase-debug.log for more info.
古いバージョンのログイン情報では失敗するのでログインし直すといいらしい
$ firebase logout
$ firebase login
OK、できた
$ firebase emulators:start
- 匿名ログインではないけどdisplayNameがないから匿名だと表示されちゃってるな
エミュレータの側でユーザを設定できる ちゃんとユーザ名が表示された
$ firebase emulators:start
:
⚠ firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠ firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration
公式のサンプルに構文エラーがあるけど。 設定ファイルを書いてJavaをインストールしたら動いた。
Firestoreがローカルで動いてるのでいつでも後腐れなく全消去できるし、雑に保存してみるか(ぇ
- というかテストコードから全消去できないとテストの挙動が変わっちゃうよな、あるはずか
- あったあった
-
Firestore の本番環境では、データベースをフラッシュするためのプラットフォーム SDK メソッドは提供されませんが、Firestore エミュレータでは、このための REST エンドポイントが提供されます。
-
Cypress+Firestore=invalid data
Cypress+Firestore+experimentalForceLongPolling=CORB
firebase.firestore().settings({ experimentalForceLongPolling: true })
- firebase - can’t use cypress to test app using using firestore local emulator - Stack Overflow
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel?... with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
- same: Firestore emulator does not work in Cypress · Issue #1975 · firebase/firebase-tools · GitHub
https://githubmemory.com/repo/firebase/firebase-js-sdk/issues/4917
you should be using the useEmulator() after the firestore.settings({ experimentalAutoDetectLongPolling: true }).
ts
const db = firebase.firestore();
// NG
db.useEmulator("localhost", 8080);
db.settings({ experimentalForceLongPolling: true });
// OK
db.settings({ experimentalForceLongPolling: true });
db.useEmulator("localhost", 8080);
it works!
- experimentalForceLongPollingをtrueにする必要がある
- useEmulatorする前にやる必要がある