LoginSignup
0
0

More than 5 years have passed since last update.

GitlabCI でLambda@Edge で動かすようのnode.js のテストを書く

Posted at

やりたいこと

  • Lambda@Edge で動かすnode.js のプログラムは今までテストコードがない状態だった
  • テストは書かないと。。。
  • プログラムがGitlabで管理されているので、CircleCIとかではなく、GitlabCIで動かします

node.js のテストについて

.gitlab-ci.yml の設定

  • Gitlab の画面上で作成される.gitlab-ci.ymlをほぼそのまま使ってます
image: node:latest

cache:
  paths:
  - lambda/cloudfrount/node_modules/

test-cloudfrount:
  script:
   - cd ./lambda/cloudfrount/
   - npm install
   - npm test

package.json の設定

  • npm init で出てくるのをほぼそのまま使ってます
{
  "name": "cloudfront",
  "version": "1.0.0",
  "description": "いい感じの説明文",
  "main": "いい感じのjs",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "./node_modules/.bin/mocha"
  },
  "author": "gessy0129",
  "license": "ISC",
  "dependencies": {
    "mocha": "^5.2.0"
  }
}

Gitlab での設定について

  • 特にないです
  • この2つのファイルをGitlabにpush すれば勝手に動きます

テストコードの場所について

  • 今回、lambda/cloudfrount/ のディレクトリだけのテストを行いました
  • そのため、テストコードはlambda/cloudfrount/test の下に入っています
0
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
0
0