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,14 +96,17 @@ export async function trackCommand(commandSignature: string) {
username, username,
}); });
}); });
await mixpanel.track(`[CLI] ${commandSignature}`, { // Don't actually call mixpanel.track() while running test cases
distinct_id: username, if (!process.env.BALENA_CLI_TEST_TYPE) {
version: packageJSON.version, await mixpanel.track(`[CLI] ${commandSignature}`, {
node: process.version, distinct_id: username,
arch: process.arch, version: packageJSON.version,
balenaUrl, // e.g. 'balena-cloud.com' or 'balena-staging.com' node: process.version,
platform: process.platform, arch: process.arch,
}); balenaUrl, // e.g. 'balena-cloud.com' or 'balena-staging.com'
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",