Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 11 commits into from
Nov 26, 2018
Merged
10 changes: 3 additions & 7 deletions samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
nareshqlogic marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@google-cloud/error-reporting": "^0.5.0",
Expand All @@ -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"
}
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
26 changes: 12 additions & 14 deletions samples/system-test/snippets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});