Skip to content

Commit 7b3ed33

Browse files
committed
include filename:line:col in e2e tests
1 parent 32aacc5 commit 7b3ed33

File tree

1 file changed

+11
-0
lines changed
  • packages/test-my-cli/operations

1 file changed

+11
-0
lines changed

packages/test-my-cli/operations/test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,23 @@ exports.create = (name, fn) => {
2929
'the test implementation function'
3030
);
3131

32+
// find the shallowest absolute filename in the call stack
33+
const callerFilename = new Error().stack
34+
.match(/\(((?:\w\:)?[\\\/][^)]+)\)/g)
35+
.pop();
36+
3237
return compose(operation(NAME, name), sequence)(
3338
assertInOperation(`misuse: ${NAME}() somehow escaped the operation`),
3439
(context0, {onActivity}, log) => {
3540
const {test: test0} = context0;
41+
const {assertCount, pass} = test0;
3642

3743
onActivity();
3844

45+
const maybeAssertFilename = (assertCount > 0) ?
46+
() => pass(callerFilename) :
47+
() => {};
48+
3949
const innerTestWithOuterContext = (test1) =>
4050
assign({}, context0, {test: test1});
4151

@@ -53,6 +63,7 @@ exports.create = (name, fn) => {
5363
`${test0.name}/${name}`,
5464
(t) => Promise.resolve(t)
5565
.then(onActivity)
66+
.then(lens(null, null)(maybeAssertFilename))
5667
.then(lens(innerTestWithOuterContext, outerTestWithInnerContext)(fn))
5768
.then(resolve)
5869
.catch(reject)

0 commit comments

Comments
 (0)