Open alexjeffburke opened 8 years ago
On node.js 0.10.43 I get this output: https://gist.github.com/papandreou/e8fbd50782e8c5d0b22f5fcf1ba1cc37
Are you talking about the "unexpected-mitm: Could not find the right place to inject the recorded exchanges" message?
Still happening with unexpected-markdown 1.6.1.
Ah, now I see it. The example in the documentation that exercises the injection mode should be marked as #evaluate:false
: https://github.com/unexpectedjs/unexpected-mitm/commit/62addf209e1185744a7ffe431c3b0a0d1c9f7283
It seems like there's a bug in either the source mapping or the injection logic, but if I change https://github.com/unexpectedjs/unexpected-mitm/blob/master/lib/unexpectedMitm.js#L375 to searchRegExp.lastIndex = 0;
it actually manages to inject the recorded exchange into documentation/assertions/any/with-http-recorded.md
8-)
Looks like it's the injectionCallsite
that points at the end marker of the last code block in the .md file rather than somewhere within the last-but-one. I have no idea -- but getting those call sites to honor source maps will probably be necessary for the injection code to work with other kinds of transpiled files.
Oh given you're diagnosis I think I know exactly what this is - the injection mode code getSourceText()s before it starts finding injection points etc. What is almost certainly happening is it's getting the original as opposed to the transpiled file. Interesting case - we end up invalidating assumptions of others... wonder if there is any good way of passing the transpiled version across?
The unexpected-mitm plugin makes use unexpected-markdown to do rendering of its documentation. Unfortunately, while the examples currently rendered are correct and work standalone something likely related to -markdown seems to interfere with the correct functioning of that plugin.
This can be seen by observed 'npm test' in unexpected-mitm - a message will be output by unexpected-mitm it has not. Note, there may not necessarily be anything to fix here (mostly due to the complex working of the -mitm plugin), but I think this might be an interesting one to investigate at some point.