Disable mixpanel.track() calls while running automated tests

Change-type: patch
This commit is contained in:
Paulo Castro 2020-07-09 19:48:06 +01:00
parent 6fe8fb7c6e
commit 17a9d71e59
2 changed files with 15 additions and 12 deletions

View File

@ -96,6 +96,8 @@ export async function trackCommand(commandSignature: string) {
username, username,
}); });
}); });
// Don't actually call mixpanel.track() while running test cases
if (!process.env.BALENA_CLI_TEST_TYPE) {
await mixpanel.track(`[CLI] ${commandSignature}`, { await mixpanel.track(`[CLI] ${commandSignature}`, {
distinct_id: username, distinct_id: username,
version: packageJSON.version, version: packageJSON.version,
@ -104,6 +106,7 @@ export async function trackCommand(commandSignature: string) {
balenaUrl, // e.g. 'balena-cloud.com' or 'balena-staging.com' balenaUrl, // e.g. 'balena-cloud.com' or 'balena-staging.com'
platform: process.platform, platform: process.platform,
}); });
}
} catch { } catch {
// ignore // ignore
} }

View File

@ -58,11 +58,11 @@
"release": "ts-node --transpile-only automation/run.ts release", "release": "ts-node --transpile-only automation/run.ts release",
"pretest": "npm run build", "pretest": "npm run build",
"test": "npm run test:source && npm run test:standalone", "test": "npm run test:source && npm run test:standalone",
"test:source": "mocha --timeout 6000 -r ts-node/register/transpile-only \"tests/**/*.spec.ts\"", "test:source": "cross-env BALENA_CLI_TEST_TYPE=source mocha --timeout 6000 -r ts-node/register/transpile-only \"tests/**/*.spec.ts\"",
"test:standalone": "npm run build:standalone && cross-env BALENA_CLI_TEST_TYPE=standalone npm run test:source", "test:standalone": "npm run build:standalone && npm run test:standalone:fast",
"test:standalone:fast": "cross-env BALENA_CLI_TEST_TYPE=standalone npm run test:source", "test:standalone:fast": "cross-env BALENA_CLI_TEST_TYPE=standalone npm run test:source",
"test:fast": "npm run build:fast && mocha --timeout 6000 -r ts-node/register/transpile-only \"tests/**/*.spec.ts\"", "test:fast": "npm run build:fast && npm run test:source",
"test:only": "npm run build:fast && mocha --timeout 6000 -r ts-node/register/transpile-only \"tests/**/${npm_config_test}.spec.ts\"", "test:only": "npm run build:fast && cross-env BALENA_CLI_TEST_TYPE=source mocha --timeout 6000 -r ts-node/register/transpile-only \"tests/**/${npm_config_test}.spec.ts\"",
"catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted", "catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted",
"ci": "npm run test && npm run catch-uncommitted", "ci": "npm run test && npm run catch-uncommitted",
"watch": "gulp watch", "watch": "gulp watch",