Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

refactor(samples): convert sample tests from ava to mocha #126

Merged
merged 2 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=8"
},
"scripts": {
"unit-test": "ava --verbose system-test/*.test.js",
"unit-test": "mocha system-test/*.test.js --timeout=600000",
"system-test": "repo-tools test app --config package.json --config-key cloud-repo-tools",
"test": "npm run unit-test && npm run system-test"
},
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "^3.0.0",
"ava": "^0.25.0",
"mocha": "^5.2.0",
"proxyquire": "^2.0.1",
"sinon": "^7.0.0"
},
Expand Down
3 changes: 2 additions & 1 deletion samples/system-test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
env:
mocha: true
rules:
node/no-unpublished-require: off
node/no-unsupported-features: off
no-empty: off
22 changes: 11 additions & 11 deletions samples/system-test/createTask.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@

'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 {runAsync} = require(`@google-cloud/nodejs-repo-tools`);
const {runAsync} = require('@google-cloud/nodejs-repo-tools');

const PROJECT_ID = process.env.GCLOUD_PROJECT;
const QUEUE = process.env.QUEUE_ID || 'my-appengine-queue';
const cmd = `node createTask.js`;
const cwd = path.join(__dirname, `..`);
const cmd = 'node createTask.js';
const cwd = path.join(__dirname, '..');

test.before(t => {
before(() => {
if (!QUEUE) {
t.fail(`You must set the QUEUE_ID environment variable!`);
assert.fail('You must set the QUEUE_ID environment variable!');
}
tools.checkCredentials();
});
test.before(tools.checkCredentials);

test.serial(`should create a task`, async t => {
it('should create a task', async () => {
const output = await runAsync(
`${cmd} --project=${PROJECT_ID} --location=us-central1 --queue=${QUEUE}`,
cwd
);
t.true(output.includes('Created task'));
assert.strictEqual(output.includes('Created task'), true);
});