prev Kozaneba開発日記

今日の一枚 image


image image Cypress環境でGoogleが「このブラウザは安全ではないのでログインさせませーん」と言ってくることがわかった、これは…どうするのがいいのか…

ログインできるとこうなる image

image

image

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

  • image
  • image
  • image 匿名ログインではないけどdisplayNameがないから匿名だと表示されちゃってるな

エミュレータの側でユーザを設定できる image image image ちゃんとユーザ名が表示された


$ 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をインストールしたら動いた。

image

Firestoreがローカルで動いてるのでいつでも後腐れなく全消去できるし、雑に保存してみるか(ぇ

  • というかテストコードから全消去できないとテストの挙動が変わっちゃうよな、あるはずか
  • あったあった

Cypress+Firestore=invalid data

Cypress+Firestore+experimentalForceLongPolling=CORB

firebase.firestore().settings({ experimentalForceLongPolling: true })

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! image

  • experimentalForceLongPollingをtrueにする必要がある
  • useEmulatorする前にやる必要がある

next Kozaneba開発日記2021-08-05