Skip to content

Commit 34de7eb

Browse files
nareshqlogicAce Nassri
authored and
Ace Nassri
committed
refactor(samples): convert sample tests from ava to mocha (#257)
1 parent 3dd87de commit 34de7eb

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

error-reporting/package.json

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
"node": ">=8"
1010
},
1111
"scripts": {
12-
"ava": "ava -T 20s --verbose test/*.test.js system-test/*.test.js",
13-
"cover": "nyc --reporter=lcov --cache ava -T 20s --verbose test/*.test.js system-test/*.test.js && nyc report",
1412
"error-test": "samples test app --msg \"Something broke!\" --url \"http://localhost:33332/error\" --port 33332 -- snippets.js express",
1513
"exception-test": "samples test app --code 500 --msg SyntaxError --url \"http://localhost:33333/exception\" --port 33333 -- snippets.js express",
16-
"system-test": "ava -T 1m --verbose system-test/*.test.js",
17-
"all-test": "npm run system-test && npm run error-test && npm run exception-test",
18-
"test": "npm run cover"
14+
"all-test": "npm run test && npm run error-test && npm run exception-test",
15+
"test": "mocha system-test/*.test.js --timeout=600000"
1916
},
2017
"dependencies": {
2118
"@google-cloud/error-reporting": "^0.5.0",
@@ -24,8 +21,7 @@
2421
},
2522
"devDependencies": {
2623
"@google-cloud/nodejs-repo-tools": "^3.0.0",
27-
"ava": "^0.25.0",
28-
"nyc": "^13.0.0",
24+
"mocha": "^5.2.0",
2925
"proxyquire": "^2.0.1",
3026
"sinon": "^7.0.0"
3127
}
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2+
env:
3+
mocha: true
24
rules:
35
node/no-unpublished-require: off
4-
node/no-unsupported-features: off
56
no-empty: off

error-reporting/system-test/snippets.test.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,22 @@
1515

1616
'use strict';
1717

18-
const path = require(`path`);
19-
const test = require(`ava`);
20-
const tools = require(`@google-cloud/nodejs-repo-tools`);
18+
const path = require('path');
19+
const assert = require('assert');
20+
const tools = require('@google-cloud/nodejs-repo-tools');
2121

22-
const cwd = path.join(__dirname, `..`);
23-
const cmd = `node snippets.js`;
22+
const cwd = path.join(__dirname, '..');
23+
const cmd = 'node snippets.js';
2424

25-
test.before(tools.checkCredentials);
25+
before(tools.checkCredentials);
2626

27-
test.serial(`should setup using implicit credentials`, async t => {
28-
t.plan(0);
27+
it('should setup using implicit credentials', async () =>
2928
// There's no output, the command should just succeed
30-
await tools.runAsync(`${cmd} setup-implicit`, cwd);
31-
});
29+
await tools.runAsync(`${cmd} setup-implicit`, cwd));
3230

33-
test.serial(`should report errors manually`, async t => {
31+
it('should report errors manually', async () => {
3432
const output = await tools.runAsync(`${cmd} manual`, cwd);
35-
t.is(output.includes('Done reporting error event!'), true);
36-
t.is(output.includes('Done reporting Error object!'), true);
37-
t.is(output.includes('Done reporting error string!'), true);
33+
assert.strictEqual(output.includes('Done reporting error event!'), true);
34+
assert.strictEqual(output.includes('Done reporting Error object!'), true);
35+
assert.strictEqual(output.includes('Done reporting error string!'), true);
3836
});

0 commit comments

Comments
 (0)