Do not polute test output with unncessarry stack trace

Signed-off-by: Theodor Gherzan <theodor@balena.io>
This commit is contained in:
Theodor Gherzan 2019-11-17 01:15:12 +00:00
parent 8589dbf3d1
commit d6adfa189f
No known key found for this signature in database
GPG Key ID: FE24E396B42287CE
2 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import LocalModeManager, {
EngineSnapshotRecord,
} from '../src/local-mode';
import Logger from '../src/logger';
import ShortStackError from './lib/errors';
describe('LocalModeManager', () => {
let dbFile: tmp.FileResult;
@ -188,7 +189,7 @@ describe('LocalModeManager', () => {
) => {
const res = sinon.createStubInstance(c);
if (removeThrows) {
res.remove.rejects(`test error removing ${type}`);
res.remove.rejects(new ShortStackError(`error removing ${type}`));
} else {
res.remove.resolves();
}

8
test/lib/errors.ts Normal file
View File

@ -0,0 +1,8 @@
import TypedError = require('typed-error');
export default class ShortStackError extends TypedError {
constructor(err: Error | string = '') {
Error.stackTraceLimit = 1;
super(err);
}
}