From ada0e8a73dd79c35bc62310680639e3623d536a4 Mon Sep 17 00:00:00 2001 From: Naresh Kumar Date: Tue, 30 Oct 2018 19:20:50 +0530 Subject: [PATCH 1/2] #3105:nodejs-logging-bunyan: Convert samples test from ava to mocha --- samples/package.json | 3 +-- samples/system-test/.eslintrc.yml | 2 ++ samples/system-test/express.test.js | 16 ++++++++-------- samples/system-test/quickstart.test.js | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/samples/package.json b/samples/package.json index bb9cd351..7e7bedd6 100644 --- a/samples/package.json +++ b/samples/package.json @@ -9,8 +9,7 @@ "node": ">=8" }, "scripts": { - "system-test": "ava -T 1m --verbose system-test/*.test.js", - "test": "npm run system-test" + "test": "mocha system-test/*.js --timeout 600000" }, "dependencies": { "@google-cloud/logging-bunyan": "^0.9.4", diff --git a/samples/system-test/.eslintrc.yml b/samples/system-test/.eslintrc.yml index c0289282..75216436 100644 --- a/samples/system-test/.eslintrc.yml +++ b/samples/system-test/.eslintrc.yml @@ -1,4 +1,6 @@ --- +env: + mocha: true rules: node/no-unpublished-require: off node/no-unsupported-features: off diff --git a/samples/system-test/express.test.js b/samples/system-test/express.test.js index 2e44e3b6..39ea6072 100644 --- a/samples/system-test/express.test.js +++ b/samples/system-test/express.test.js @@ -16,7 +16,7 @@ 'use strict'; const path = require(`path`); -const test = require(`ava`); +const assert = require(`assert`); const tools = require(`@google-cloud/nodejs-repo-tools`); const execa = require(`execa`); const delay = require(`delay`); @@ -24,10 +24,10 @@ const {Logging} = require('@google-cloud/logging'); const logging = new Logging(); const got = require('got'); -test.before(tools.checkCredentials); +before(tools.checkCredentials); -test.serial(`should write using bunyan`, async t => { - t.plan(4); +it(`should write using bunyan`, async () => { + //t.plan(4); // Start the express server. execa(process.execPath, ['express.js'], { @@ -47,9 +47,9 @@ test.serial(`should write using bunyan`, async t => { // Make sure the log was written to Stackdriver Logging. const log = logging.log('bunyan_log'); const entries = (await log.getEntries({pageSize: 1}))[0]; - t.is(entries.length, 1); + assert.strictEqual(entries.length, 1); const entry = entries[0]; - t.is('this is an info log message', entry.data.message); - t.truthy(entry.metadata.trace, 'should have a trace property'); - t.truthy(entry.metadata.trace.match(/projects\/.*\/traces\/.*/)); + assert.strictEqual('this is an info log message', entry.data.message); + assert.ok(entry.metadata.trace, 'should have a trace property'); + assert.ok(entry.metadata.trace.match(/projects\/.*\/traces\/.*/)); }); diff --git a/samples/system-test/quickstart.test.js b/samples/system-test/quickstart.test.js index 64c640d8..35b6b894 100644 --- a/samples/system-test/quickstart.test.js +++ b/samples/system-test/quickstart.test.js @@ -16,15 +16,15 @@ 'use strict'; const path = require(`path`); -const test = require(`ava`); +const assert = require(`assert`); const tools = require(`@google-cloud/nodejs-repo-tools`); -test.before(tools.checkCredentials); +before(tools.checkCredentials); -test.serial(`should write using bunyan`, async t => { +it(`should write using bunyan`, async () => { const output = await tools.runAsync( `node quickstart.js`, path.join(__dirname, `..`) ); - t.is(output.includes('99%'), true); + assert.strictEqual(output.includes('99%'), true); }); From 9997d034bac51a391d9ed11454246fc085992f5f Mon Sep 17 00:00:00 2001 From: Naresh Kumar Date: Wed, 31 Oct 2018 12:50:28 +0530 Subject: [PATCH 2/2] Remove comment line --- samples/system-test/express.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/system-test/express.test.js b/samples/system-test/express.test.js index 39ea6072..0e07898b 100644 --- a/samples/system-test/express.test.js +++ b/samples/system-test/express.test.js @@ -27,8 +27,6 @@ const got = require('got'); before(tools.checkCredentials); it(`should write using bunyan`, async () => { - //t.plan(4); - // Start the express server. execa(process.execPath, ['express.js'], { cwd: path.join(__dirname, `..`),