Skip to content

Commit f1b697c

Browse files
committed
do not truncate error messages by default
1 parent 21cf5df commit f1b697c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const internals = {
1717

1818

1919
exports.settings = {
20-
truncateMessages: true,
20+
truncateMessages: false,
2121
comparePrototypes: true
2222
};
2323

test/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,16 @@ describe('expect()', () => {
125125
it('asserts on invalid condition (large array, display truncated)', (done) => {
126126

127127
let exception = false;
128+
const origTruncate = Code.settings.truncateMessages;
128129
try {
130+
Code.settings.truncateMessages = true;
129131
Code.expect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]).to.be.a.string();
130132
}
131133
catch (err) {
132134
exception = err;
133135
}
134136

137+
Code.settings.truncateMessages = origTruncate;
135138
Hoek.assert(exception.message === 'Expected [Array(18)] to be a string but got \'array\'', exception);
136139
done();
137140
});
@@ -156,13 +159,16 @@ describe('expect()', () => {
156159
it('asserts on invalid condition (large object, display truncated)', (done) => {
157160

158161
let exception = false;
162+
const origTruncate = Code.settings.truncateMessages;
159163
try {
164+
Code.settings.truncateMessages = true;
160165
Code.expect({ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }).to.be.a.string();
161166
}
162167
catch (err) {
163168
exception = err;
164169
}
165170

171+
Code.settings.truncateMessages = origTruncate;
166172
Hoek.assert(exception.message === 'Expected { Object (a, b, ...) } to be a string but got \'object\'', exception);
167173
done();
168174
});
@@ -204,13 +210,16 @@ describe('expect()', () => {
204210
it('asserts on invalid condition (long object values, display truncated)', (done) => {
205211

206212
let exception = false;
213+
const origTruncate = Code.settings.truncateMessages;
207214
try {
215+
Code.settings.truncateMessages = true;
208216
Code.expect({ a: 12345678901234567890, b: 12345678901234567890 }).to.be.a.string();
209217
}
210218
catch (err) {
211219
exception = err;
212220
}
213221

222+
Code.settings.truncateMessages = origTruncate;
214223
Hoek.assert(exception.message === 'Expected { Object (a, b) } to be a string but got \'object\'', exception);
215224
done();
216225
});
@@ -235,13 +244,16 @@ describe('expect()', () => {
235244
it('asserts on invalid condition (long string, display truncated)', (done) => {
236245

237246
let exception = false;
247+
const origTruncate = Code.settings.truncateMessages;
238248
try {
249+
Code.settings.truncateMessages = true;
239250
Code.expect('{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }').to.be.a.number();
240251
}
241252
catch (err) {
242253
exception = err;
243254
}
244255

256+
Code.settings.truncateMessages = origTruncate;
245257
Hoek.assert(exception.message === 'Expected \'{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g...\' to be a number but got \'string\'', exception);
246258
done();
247259
});

0 commit comments

Comments
 (0)