File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
packages/test-my-cli/operations Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,23 @@ exports.create = (name, fn) => {
29
29
'the test implementation function'
30
30
) ;
31
31
32
+ // find the shallowest absolute filename in the call stack
33
+ const callerFilename = new Error ( ) . stack
34
+ . match ( / \( ( (?: \w \: ) ? [ \\ \/ ] [ ^ ) ] + ) \) / g)
35
+ . pop ( ) ;
36
+
32
37
return compose ( operation ( NAME , name ) , sequence ) (
33
38
assertInOperation ( `misuse: ${ NAME } () somehow escaped the operation` ) ,
34
39
( context0 , { onActivity} , log ) => {
35
40
const { test : test0 } = context0 ;
41
+ const { assertCount, pass} = test0 ;
36
42
37
43
onActivity ( ) ;
38
44
45
+ const maybeAssertFilename = ( assertCount > 0 ) ?
46
+ ( ) => pass ( callerFilename ) :
47
+ ( ) => { } ;
48
+
39
49
const innerTestWithOuterContext = ( test1 ) =>
40
50
assign ( { } , context0 , { test : test1 } ) ;
41
51
@@ -53,6 +63,7 @@ exports.create = (name, fn) => {
53
63
`${ test0 . name } /${ name } ` ,
54
64
( t ) => Promise . resolve ( t )
55
65
. then ( onActivity )
66
+ . then ( lens ( null , null ) ( maybeAssertFilename ) )
56
67
. then ( lens ( innerTestWithOuterContext , outerTestWithInnerContext ) ( fn ) )
57
68
. then ( resolve )
58
69
. catch ( reject )
You can’t perform that action at this time.
0 commit comments