From 50aff33ff323998096f4109d0c97b15af7c4092e Mon Sep 17 00:00:00 2001 From: nareshqlogic <44403913+nareshqlogic@users.noreply.github.com> Date: Mon, 26 Nov 2018 21:19:29 +0530 Subject: [PATCH] refactor(samples): convert sample tests from ava to mocha (#257) --- error-reporting/package.json | 10 +++----- error-reporting/system-test/.eslintrc.yml | 3 ++- error-reporting/system-test/snippets.test.js | 26 +++++++++----------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/error-reporting/package.json b/error-reporting/package.json index 548290b6ce..3acf6b2f3b 100644 --- a/error-reporting/package.json +++ b/error-reporting/package.json @@ -9,13 +9,10 @@ "node": ">=8" }, "scripts": { - "ava": "ava -T 20s --verbose test/*.test.js system-test/*.test.js", - "cover": "nyc --reporter=lcov --cache ava -T 20s --verbose test/*.test.js system-test/*.test.js && nyc report", "error-test": "samples test app --msg \"Something broke!\" --url \"http://localhost:33332/error\" --port 33332 -- snippets.js express", "exception-test": "samples test app --code 500 --msg SyntaxError --url \"http://localhost:33333/exception\" --port 33333 -- snippets.js express", - "system-test": "ava -T 1m --verbose system-test/*.test.js", - "all-test": "npm run system-test && npm run error-test && npm run exception-test", - "test": "npm run cover" + "all-test": "npm run test && npm run error-test && npm run exception-test", + "test": "mocha system-test/*.test.js --timeout=600000" }, "dependencies": { "@google-cloud/error-reporting": "^0.5.0", @@ -24,8 +21,7 @@ }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "^3.0.0", - "ava": "^0.25.0", - "nyc": "^13.0.0", + "mocha": "^5.2.0", "proxyquire": "^2.0.1", "sinon": "^7.0.0" } diff --git a/error-reporting/system-test/.eslintrc.yml b/error-reporting/system-test/.eslintrc.yml index c0289282a6..0ab526f52b 100644 --- a/error-reporting/system-test/.eslintrc.yml +++ b/error-reporting/system-test/.eslintrc.yml @@ -1,5 +1,6 @@ --- +env: + mocha: true rules: node/no-unpublished-require: off - node/no-unsupported-features: off no-empty: off diff --git a/error-reporting/system-test/snippets.test.js b/error-reporting/system-test/snippets.test.js index b5b4088c6b..f5f155e350 100644 --- a/error-reporting/system-test/snippets.test.js +++ b/error-reporting/system-test/snippets.test.js @@ -15,24 +15,22 @@ 'use strict'; -const path = require(`path`); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); +const path = require('path'); +const assert = require('assert'); +const tools = require('@google-cloud/nodejs-repo-tools'); -const cwd = path.join(__dirname, `..`); -const cmd = `node snippets.js`; +const cwd = path.join(__dirname, '..'); +const cmd = 'node snippets.js'; -test.before(tools.checkCredentials); +before(tools.checkCredentials); -test.serial(`should setup using implicit credentials`, async t => { - t.plan(0); +it('should setup using implicit credentials', async () => // There's no output, the command should just succeed - await tools.runAsync(`${cmd} setup-implicit`, cwd); -}); + await tools.runAsync(`${cmd} setup-implicit`, cwd)); -test.serial(`should report errors manually`, async t => { +it('should report errors manually', async () => { const output = await tools.runAsync(`${cmd} manual`, cwd); - t.is(output.includes('Done reporting error event!'), true); - t.is(output.includes('Done reporting Error object!'), true); - t.is(output.includes('Done reporting error string!'), true); + assert.strictEqual(output.includes('Done reporting error event!'), true); + assert.strictEqual(output.includes('Done reporting Error object!'), true); + assert.strictEqual(output.includes('Done reporting error string!'), true); });