LoginSignup
2
1

More than 5 years have passed since last update.

Azure Pipelines上でJestを非対話モードで実行する

Last updated at Posted at 2019-04-04

はじめに

Azure Pipelines上でJestを使ったCI環境を構築するときに yarn test でテストを実行してしまうと対話モードで起動してしまい、CIが止まってしまいます。

本稿では、非対話モードでJestを使ってCIを実行する方法を紹介します。

環境

  • Azure Pipelines
  • create-react-appで作成したReactプロジェクト
  • パッケージマネージャ
    • yarn

azure-pipelines.ymlの設定

  • 非対話モードでJestを実行するためには環境変数 CI=true を設定する必要があります。

  • 以下のファイルを作成して、Build Pipelineに設定します。

azure-pipelines.yml
variables:
  CI: true
jobs:
- job: Ubuntu
  pool:
    vmImage: 'ubuntu-16.04'
  strategy:
    matrix:
      node_10_x:
        node_version: 10.x
  steps:
  - script: |
      yarn
    displayName: 'node moduleをインストール'
  - script: |
      yarn test
    displayName: 'テスト'
  - script: |
      yarn build
    displayName: 'ビルド'
2
1
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
2
1