Skip to content

Commit

Permalink
refactor(samples): convert sample tests from ava to mocha (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
nareshqlogic authored and Ace Nassri committed Nov 11, 2022
1 parent 85e709e commit 50aff33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
10 changes: 3 additions & 7 deletions error-reporting/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"
},
"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 error-reporting/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 error-reporting/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);
});

0 comments on commit 50aff33

Please sign in to comment.