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
Test.prototype._assert fails to identify source file/line for calls to assert methods inside Promise/then context #515
Comments
This may be because of lambda functions. Try using named function expressions instead. Lambdas do not have names |
Arrow functions ("lambdas" can falsely imply traits JS doesn't have) don't have names, indeed - they can infer them, but in this case, they can't, so they're anonymous. However, that shouldn't affect what line is indicated, only what name is available to help debugging. I'd be interested in a PR with a failing test case; if you're willing to submit one, it'd be great to compare with a named function as well as an anonymous one, just to eliminate that as the issue. |
I can invest more time here, but it’s worth pointing out that the RegExp used by the project (line 304 in the excerpt above) does not successfully match the last line of the sample stack in the relevant comment (line 281) and furthermore that the unmatched sample line has exactly the problematic form that appears in the repro I already provided above. To expand upon my suggestion in the original comment, it seems the RegExp being used requires a trailing |
Would you be OK making a PR with that fix and regression tests? :-) |
My approach would be to start by pulling the stack parsing code out into its own module so that it can be exercised directly by test code, then to add a new test file to verify the sample forms in the comment are all recognized correctly. I think the new function would take as input the stack array and return an object with properties for each of the |
I'd prefer not to exercise it directly; instead to write the tests, test them, and validate the output. Check the existing tests for how to do that with tap. |
The code inside the following loop seems to fail the
RegExp
match against the non-tape
stack frames in the second case, so theat:
field is missing from the output. (Specifically, theres
object doesn't get itsfunctionName
,file
,line
,column
, orat
properties set.) An update of theRegExp
to match lines likeat /home/pi/tape-issue/tape-issue.js:9:10
would seem to address this problem.https://github.com/substack/tape/blob/0b5804d43068602e1615dfd395a3d85949bb03da/lib/test.js#L268-L328
The text was updated successfully, but these errors were encountered: