5
0

More than 1 year has passed since last update.

【Vercel】自動テスト【Next.js】

Posted at

Vercelにデプロイする

まず下記の Vercel サイトの右上の"Sign Up"からGitアカウントでサインアップしてください。

スクリーンショット 2022-05-06 2.34.01.png

スクリーンショット 2022-05-06 2.35.03.png

サインアップが完了したら画面左側のImport Git Repositoryの入力フォームをクリックし、Add GitHub Accountを選択してください。

スクリーンショット 2022-05-06 2.39.36.png

GitHubのページが表示されますのでRepository accessの箇所のOnly select repositoriesを選択し、リポジトリを選択します。

スクリーンショット 2022-05-06 2.44.34.png

選択したらSaveをクリックしてください。

するとImport Git Repositoryに先ほど選択したリポジトリが表示されます。
importをクリックします。
スクリーンショット 2022-05-06 2.47.16.png

表示された画面のConfigure Projectに必要事項を入力します。
スクリーンショット 2022-05-06 2.48.16.png

入力ができたらDeployをクリックします。

しばらくすると以下のような画面が表示されます。

スクリーンショット 2022-05-06 2.54.18のコピー.png

赤枠内をクリックして正常に動作していればデプロイは完了です。

自動テストの設定

プロジェクトのダッシュボードを開きます。
スクリーンショット 2022-06-30 午前0.41.40.png

settingsをクリックします。
スクリーンショット 2022-06-30 午前0.41.52.png

Generalの中のBuild & Development Settingを探します。
Build & Development SettingBUILD COMMANDOVERRIDEをオンにします。
スクリーンショット 2022-06-30 午前0.43.52のコピー.png

下画像のようにyarn test && next buildまたはnpm test && next buildと入力します。
スクリーンショット 2022-06-30 午前0.46.16.png

これでgit pushした際にテストを実行し、テストが通った場合のみbuildとデプロイが実行されるようになります。

5
0
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
5
0