Skip to content

Commit f01090b

Browse files
committed
Shorten the plan stack.
I'm not sure we need more than a depth of 1.
1 parent 761c2e3 commit f01090b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Test.prototype._setAssertError = function (err) {
7777
this.assertError = err;
7878
};
7979

80-
Test.prototype.plan = function (count) {
80+
Test.prototype.plan = function (count, planStack) {
8181
if (typeof count !== 'number') {
8282
throw new TypeError('Expected a number');
8383
}
@@ -86,7 +86,7 @@ Test.prototype.plan = function (count) {
8686

8787
// in case the `planCount` doesn't match `assertCount,
8888
// we need the stack of this function to throw with a useful stack
89-
this.planStack = new Error().stack;
89+
this.planStack = planStack || new Error().stack;
9090
};
9191

9292
Test.prototype._run = function () {
@@ -265,7 +265,6 @@ Test.prototype._publicApi = function () {
265265

266266
function PublicApi(test) {
267267
this._test = test;
268-
this.plan = test.plan.bind(test);
269268
this.skip = new SkipApi(test);
270269
}
271270

@@ -303,6 +302,17 @@ PublicApi.prototype = enhanceAssert({
303302
onError: onAssertionEvent
304303
});
305304

305+
PublicApi.prototype.plan = plan;
306+
307+
function plan(ct) {
308+
var limitBefore = Error.stackTraceLimit;
309+
Error.stackTraceLimit = 1;
310+
var obj = {};
311+
Error.captureStackTrace(obj, plan);
312+
Error.stackTraceLimit = limitBefore;
313+
this._test.plan(ct, obj.stack);
314+
}
315+
306316
// Getters
307317
[
308318
'assertCount',

0 commit comments

Comments
 (0)