-
Notifications
You must be signed in to change notification settings - Fork 21
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
parse does not find name for test.each block #29
Comments
the parsed object for this block:
|
Looks like you've done a great job identifying the root cause of the problem. How would you feel about trying to update the parser @firsttris? |
hey @seanpoulter i will take a look at extending the parser. this should be something im capable of just a question about this comment: |
📣 Quick question for the maintainers/contributors: Are we good with a major/breaking change to consolidate the test parsers into only one using Babel 7? That'd drop the TypeScript parser. Thanks! 👍 -- Those are great questions @firsttris! The comment in typescript_parser.js is from @connectdotz's epic PR #9 🎉. I'll try to tell the story again in my own words for context:
The "new" parser is actually the ability for Babel to parse TypeScript. That means we can remove the TypeScript parser and handle both types of files with Babel. It was one of the big changes that was introduced with the release of Babel 7. I don't think there's a parser in the Jest repository any more. I had a quick look and the only hints I could find were to parse the snapshots.
Is it the best choice of parser? You may not like my answer: "it depends". We've been maintaining the parser for the few use cases that we can think of, mostly for vscode-jest. As you've discovered, we haven't been doing the best job keeping up with changes or building the team of folks to help maintain it. Despite that, the parser has been stable for quite a while. I can say that when I was able to use Jest and the VS Code Jest extension, I was really happy with it. If you're looking around at other test parsers, @Raathigesh has his own parser for majestic: https://github.com/Raathigesh/majestic/blob/master/server/services/ast/parser.ts -- Have you worked with the abstract syntax tree (AST) or a parser before? I've found http://astexplorer.net really helpful to experiment before I had Babel working from the CLI. |
@seanpoulter now i have a much better understanding. My understanding is that majestic is also using @babel/parser which is the parser of Babel 7.x I was just thinking if i could do the parsing the same way that Jest was doing it, it would probably be the best option. Is Jest also using the babel/parser? thx for your help |
@seanpoulter did a pretty good explanation. Yes, we do want to replace the custom typescript parser with a more maintained one, like babel-parser, provided:
|
Just wanted to give a little background why i even extended your parser: I'm the author of vscode-jest-runner. At some point with my extension i wanted to be able to contruct a full unqiue test path. something like: jest -t "describeName childDescribeName testName" I started searching for a Jest parser. After some time i found jest-editor-support. Some while ago a user created a bug that "test.each" is not working. Since @seanpoulter was so kind and explained me everything. Extending two parser (babylon and typescript) with test.each seemed not the best option? Did not run into issues with "template literal and dynamic strings" with my extension yet. Probably a test could verify this? thx for your help |
I saw there is already a test file for template-literals in fixtures/template-literal.example. Small runtime template-literal Test:
process.env.USER was "firsttris" during runtime i let babel/parser parse this result: it was not able to resolve my username. does this answer your question about template-literal strings with runtime context? |
@firsttris thanks for the context. Apology if I came across as unappreciative. Indeed the unselfish act of making open-source repo better, even during our weekends 😏, is what made the community so great! 😄 Anyway, come back to the typescript parser issue.
Jest doesn't use this package directly. It was able to resolve all the dynamic names etc because it is actually running the tests, not parsing the code.
Yes, it does. And I also looked at the majestic's inspector code, it didn't seem to resolve the variable either.
We do and I think you will too, eventually. Even Anyway, I am pretty convinced now that the dynamic strings will not be resolved in a static parser. I shall drop that as a parser enhancement wish-list... As I mentioned in the comment, it is always our desire to move to babel's, actually, we almost did that when this package is still part of jest repo... Change in this package might not be hard but I know the compatibility testing and potential interruption of the user experience might be significant (will add more about this in your PR), therefore we didn't pull the trigger then... But now I saw PR #32 for typescript conversion, another item in my personal wish list, I started to think, if there is no strong objection (@stephtr @seanpoulter), maybe this is a good time to consider a new major release? If we have to do a lot of integration tests for each change, we might as well do them at the same time...? |
Hey guys! I am using a VS Code extension which depends on this project. Could you tell me, what is the status of this issue and related PR? Thank you! |
Hey @pbotsman. Well, it looks like that PR has been stalled for over a month. If you've got the interest and capacity, I'm sure we'd all appreciate your help having a look with fresh eyes and "managing" it to get it back on track. What's left to do? I can't assign you as a reviewer (yet). 😉 |
i think this isuse is resolved now, please re-open if im wrong. |
https://jestjs.io/docs/en/api#testeachtablename-fn-timeout
(note: its not possible to put a test.each inside a "it" or a "test" )
parser outputs a warning if he detects such a block.
The text was updated successfully, but these errors were encountered: