From 793df785927393ac1b38008b4b44b83108192422 Mon Sep 17 00:00:00 2001 From: Naresh Kumar Date: Mon, 18 Feb 2019 19:38:43 +0530 Subject: [PATCH] refactor(headless-chrome):ava to mocha --- functions/headless-chrome/package.json | 5 ++-- functions/headless-chrome/test/index.test.js | 28 +++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/functions/headless-chrome/package.json b/functions/headless-chrome/package.json index 6183f0a066..c452b566a3 100644 --- a/functions/headless-chrome/package.json +++ b/functions/headless-chrome/package.json @@ -12,14 +12,15 @@ "node": ">=8" }, "scripts": { - "e2e-test": "export FUNCTIONS_CMD='gcloud beta functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" ava -T 20s --verbose test/*.test.js" + "e2e-test": "export FUNCTIONS_CMD='gcloud beta functions' && sh test/updateFunctions.sh && BASE_URL=\"https://$GCF_REGION-$GCLOUD_PROJECT.cloudfunctions.net/\" && npm run test", + "test": "mocha test/*.test.js --timeout=60000" }, "dependencies": { "puppeteer": "^1.6.2" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "0.25.0", + "mocha": "^5.2.0", "supertest": "^3.0.0" }, "cloud-repo-tools": { diff --git a/functions/headless-chrome/test/index.test.js b/functions/headless-chrome/test/index.test.js index b276385453..565593c8c5 100644 --- a/functions/headless-chrome/test/index.test.js +++ b/functions/headless-chrome/test/index.test.js @@ -13,27 +13,25 @@ * limitations under the License. */ -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); -const supertest = require(`supertest`); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); +const supertest = require('supertest'); const BASE_URL = process.env.BASE_URL; -test.before(`Must specify BASE_URL`, t => { - t.truthy(BASE_URL); +before('Must specify BASE_URL', () => { + assert.ok(BASE_URL); + tools.checkCredentials(); }); -test.before(tools.checkCredentials); - -test.cb(`screenshot: should return a screenshot`, t => { - supertest(BASE_URL) - .get(`/screenshot?url=https://example.com`) +it('screenshot: should return a screenshot', async () => { + await supertest(BASE_URL) + .get('/screenshot?url=https://example.com') .send() .expect(200) .expect(response => { - t.is(response.type, `image/png`); - t.true(response.body instanceof Buffer); - t.true(response.body.length > 0); - }) - .end(t.end); + assert.strictEqual(response.type, 'image/png'); + assert.strictEqual(response.body instanceof Buffer, true); + assert.strictEqual(response.body.length > 0, true); + }); });