From ade5cbba31e2e92b20f024e60c5263dc3b52bd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 28 Jun 2018 11:20:12 +0800 Subject: [PATCH] add circleci support --- .circleci/config.yml | 23 +++++++++++++++++++++++ src/e2e/login.e2e.js | 6 ++++++ tests/fix_puppeteer.sh | 8 ++++++++ 3 files changed, 37 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 tests/fix_puppeteer.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..a6e49b6e --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,23 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/node:8.11.2 + steps: + - checkout + - run: npm install + - run: npm run build + test: + docker: + - image: circleci/node:8.11.2 + steps: + - checkout + - run: sh ./tests/fix_puppeteer.sh + - run: npm install + - run: npm run test:all +workflows: + version: 2 + build_and_test: + jobs: + - build + - test \ No newline at end of file diff --git a/src/e2e/login.e2e.js b/src/e2e/login.e2e.js index a102a351..298dbca9 100644 --- a/src/e2e/login.e2e.js +++ b/src/e2e/login.e2e.js @@ -17,6 +17,9 @@ describe('Login', () => { afterEach(() => page.close()); it('should login with failure', async () => { + await page.waitForSelector('#userName', { + timeout: 2000, + }); await page.type('#userName', 'mockuser'); await page.type('#password', 'wrong_password'); await page.click('button[type="submit"]'); @@ -24,6 +27,9 @@ describe('Login', () => { }); it('should login successfully', async () => { + await page.waitForSelector('#userName', { + timeout: 2000, + }); await page.type('#userName', 'admin'); await page.type('#password', '888888'); await page.click('button[type="submit"]'); diff --git a/tests/fix_puppeteer.sh b/tests/fix_puppeteer.sh new file mode 100644 index 00000000..56c2d387 --- /dev/null +++ b/tests/fix_puppeteer.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +apt-get update +apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ + libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ + libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \ + libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \ + ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget -- GitLab