Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected-markdown does not allow a working example to be placed in documentation #3

Open
alexjeffburke opened this issue Apr 5, 2016 · 6 comments

Comments

@alexjeffburke
Copy link
Member

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.

@papandreou
Copy link
Member

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?

@papandreou
Copy link
Member

Still happening with unexpected-markdown 1.6.1.

@papandreou
Copy link
Member

Ah, now I see it. The example in the documentation that exercises the injection mode should be marked as #evaluate:false: unexpectedjs/unexpected-mitm@62addf2

@papandreou
Copy link
Member

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-)

@papandreou
Copy link
Member

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.

@alexjeffburke
Copy link
Member Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants