@@ -77,7 +77,7 @@ Test.prototype._setAssertError = function (err) {
77
77
this . assertError = err ;
78
78
} ;
79
79
80
- Test . prototype . plan = function ( count ) {
80
+ Test . prototype . plan = function ( count , planStack ) {
81
81
if ( typeof count !== 'number' ) {
82
82
throw new TypeError ( 'Expected a number' ) ;
83
83
}
@@ -86,7 +86,7 @@ Test.prototype.plan = function (count) {
86
86
87
87
// in case the `planCount` doesn't match `assertCount,
88
88
// we need the stack of this function to throw with a useful stack
89
- this . planStack = new Error ( ) . stack ;
89
+ this . planStack = planStack ;
90
90
} ;
91
91
92
92
Test . prototype . _run = function ( ) {
@@ -265,7 +265,6 @@ Test.prototype._publicApi = function () {
265
265
266
266
function PublicApi ( test ) {
267
267
this . _test = test ;
268
- this . plan = test . plan . bind ( test ) ;
269
268
this . skip = new SkipApi ( test ) ;
270
269
}
271
270
@@ -303,6 +302,15 @@ PublicApi.prototype = enhanceAssert({
303
302
onError : onAssertionEvent
304
303
} ) ;
305
304
305
+ PublicApi . prototype . plan = function plan ( ct ) {
306
+ var limitBefore = Error . stackTraceLimit ;
307
+ Error . stackTraceLimit = 1 ;
308
+ var obj = { } ;
309
+ Error . captureStackTrace ( obj , plan ) ;
310
+ Error . stackTraceLimit = limitBefore ;
311
+ this . _test . plan ( ct , obj . stack ) ;
312
+ } ;
313
+
306
314
// Getters
307
315
[
308
316
'assertCount' ,
0 commit comments