Skip to content

Commit 8311347

Browse files
committed
fix: samples test
1 parent 079c8a9 commit 8311347

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

packages/google-monitoring-dashboard/samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
"chai": "^4.2.0",
2121
"mocha": "^8.0.0"
2222
}
23-
}
23+
}

packages/google-monitoring-dashboard/samples/test/quickstart.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@
1818
const path = require('path');
1919
const {assert} = require('chai');
2020
const cp = require('child_process');
21-
const {describe, it} = require('mocha');
21+
const {describe, it, before} = require('mocha');
22+
const {
23+
DashboardsServiceClient,
24+
} = require('@google-cloud/monitoring-dashboards');
2225

26+
// Creates a client
27+
const ds = new DashboardsServiceClient();
2328
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2429

2530
const cwd = path.join(__dirname, '..');
2631

27-
const PROJECT_ID = process.env.GCLOUD_PROJECT;
28-
2932
describe('Sample Integration Tests', () => {
33+
let projectId;
34+
before(async () => {
35+
projectId = await ds.getProjectId();
36+
});
3037
it('should run quickstart.js', async () => {
31-
const stdout = execSync(`node ./quickstart.js projects/${PROJECT_ID}`, {
38+
const stdout = execSync(`node ./quickstart.js projects/${projectId}`, {
3239
cwd,
3340
});
3441
// build should have exited with success status.

0 commit comments

Comments
 (0)