Merge pull request #1989 from balena-io/improve-tests

Improve tests
This commit is contained in:
bulldozer-balena[bot] 2020-08-11 16:25:57 +00:00 committed by GitHub
commit 71ff73c641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 27 deletions

View File

@ -59,11 +59,11 @@
"release": "ts-node --transpile-only automation/run.ts release",
"pretest": "npm run build",
"test": "npm run test:source && npm run test:standalone",
"test:source": "cross-env BALENA_CLI_TEST_TYPE=source mocha --timeout 12000 -r ts-node/register/transpile-only \"tests/**/*.spec.ts\"",
"test:source": "cross-env BALENA_CLI_TEST_TYPE=source mocha",
"test:standalone": "npm run build:standalone && npm run test:standalone:fast",
"test:standalone:fast": "cross-env BALENA_CLI_TEST_TYPE=standalone mocha --timeout 12000 -r ts-node/register/transpile-only \"tests/**/*.spec.ts\"",
"test:standalone:fast": "cross-env BALENA_CLI_TEST_TYPE=standalone mocha",
"test:fast": "npm run build:fast && npm run test:source",
"test:only": "npm run build:fast && cross-env BALENA_CLI_TEST_TYPE=source mocha --timeout 12000 -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 \"tests/**/${npm_config_test}.spec.ts\"",
"catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted",
"ci": "npm run test && npm run catch-uncommitted",
"watch": "gulp watch",
@ -91,6 +91,13 @@
"pre-commit": "node automation/check-npm-version.js && node automation/check-doc.js"
}
},
"mocha": {
"reporter": "spec",
"require": "ts-node/register/transpile-only",
"file": "./tests/config-tests",
"timeout": 12000,
"_": "tests/**/*.spec.ts"
},
"oclif": {
"bin": "balena",
"commands": "./build/actions-oclif",

View File

@ -15,9 +15,6 @@
* limitations under the License.
*/
// tslint:disable-next-line:no-var-requires
require('../config-tests'); // required for side effects
import { expect } from 'chai';
import mock = require('mock-require');
import { promises as fs } from 'fs';

View File

@ -15,9 +15,6 @@
* limitations under the License.
*/
// tslint:disable-next-line:no-var-requires
require('../config-tests'); // required for side effects
import { expect } from 'chai';
import { promises as fs } from 'fs';
import * as path from 'path';

View File

@ -15,9 +15,6 @@
* limitations under the License.
*/
// tslint:disable-next-line:no-var-requires
require('../config-tests'); // required for side effects
import { expect } from 'chai';
import { promises as fs } from 'fs';
import * as path from 'path';

View File

@ -15,18 +15,21 @@
* limitations under the License.
*/
import { setMaxListeners } from '../build/app-common';
import { set as setEsVersion } from '@balena/es-version';
// Set the desired es version for downstream modules that support it
setEsVersion('es2018');
setMaxListeners(35); // it appears that 'nock' adds a bunch of listeners - bug?
import * as tmp from 'tmp';
tmp.setGracefulCleanup();
// Use a temporary dir for tests data
process.env.BALENARC_DATA_DIRECTORY = tmp.dirSync().name;
import { EventEmitter } from 'events';
EventEmitter.defaultMaxListeners = 35; // it appears that 'nock' adds a bunch of listeners - bug?
// SL: Looks like it's not nock causing this, as have seen the problem triggered from help.spec,
// which is not using nock. Perhaps mocha/chai? (unlikely), or something in the CLI?
import { config as chaiCfg } from 'chai';
function configChai() {
chaiCfg.showDiff = true;
// enable diff comparison of large objects / arrays
chaiCfg.truncateThreshold = 0;
}
configChai();
chaiCfg.showDiff = true;
// enable diff comparison of large objects / arrays
chaiCfg.truncateThreshold = 0;

View File

@ -15,8 +15,6 @@
* limitations under the License.
*/
import './config-tests'; // required for side effects
import { execFile } from 'child_process';
import intercept = require('intercept-stdout');
import * as _ from 'lodash';

View File

@ -15,9 +15,6 @@
* limitations under the License.
*/
// tslint:disable-next-line:no-var-requires
require('./../config-tests'); // required for side effects
import { expect } from 'chai';
import * as _ from 'lodash';
import * as path from 'path';