mirror of
https://github.com/knex/knex.git
synced 2025-07-13 12:00:55 +00:00
33 lines
872 B
JavaScript
33 lines
872 B
JavaScript
'use strict';
|
|
const saveAsyncStack = require('../../../lib/util/save-async-stack');
|
|
const chai = require('chai');
|
|
|
|
describe('saveAsyncStack', function () {
|
|
it('should store an error stack on passed object', function () {
|
|
const fakeInstance = {
|
|
client: {
|
|
config: {
|
|
asyncStackTraces: true,
|
|
},
|
|
},
|
|
};
|
|
saveAsyncStack(fakeInstance, 1);
|
|
|
|
const { error, lines } = fakeInstance._asyncStack;
|
|
const stackByLines = error.stack.split('\n');
|
|
const asyncStack = stackByLines.slice(lines);
|
|
|
|
chai.expect(asyncStack[0]).to.match(/at saveAsyncStack /);
|
|
});
|
|
|
|
it('should not store an error stack when config is disabled', function () {
|
|
const fakeInstance = {
|
|
client: {
|
|
config: {},
|
|
},
|
|
};
|
|
saveAsyncStack(fakeInstance, 1);
|
|
chai.expect(fakeInstance._asyncStack).to.be.undefined;
|
|
});
|
|
});
|