LoginSignup
0
2

More than 3 years have passed since last update.

firebase functionをローカル環境でテストする。

Posted at

はじめに

firebase functionをローカル環境でテストする方法を説明します。

環境/前提

<LABEL>-<MESSAGE><LABEL>-<MESSAGE>

Node.jsで既にfunctionが作成されていること。
functionがonCall()で作成されていること。

手順

Firebase CLI をインストールする

npm install -g firebase-tools

ローカル環境のfunctionを利用するように設定する。

コード上のfunctionを利用している箇所に、下記の設定を追記します。

xx.ts
  //追記箇所
  firebase.functions().useFunctionsEmulator("http://localhost:[port番号]");

  //function利用箇所
  const function = firebase.functions().httpsCallable('[function名]');
  function();

エミュレータを実行する

firebase emulators:start

以上の手順で、firebase functionをローカル環境でテストすることができます。

参考

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2