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

Plugin doesn't recognize steps that use `` instead of '' or "" #101

Closed
onthespotqa opened this issue Oct 6, 2022 · 9 comments Β· Fixed by #107
Closed

Plugin doesn't recognize steps that use `` instead of '' or "" #101

onthespotqa opened this issue Oct 6, 2022 · 9 comments Β· Fixed by #107

Comments

@onthespotqa
Copy link

πŸ‘“ What did you see?

Extension does not recognize steps that use backticks instead of quotes.

βœ… What did you expect to see?

I would expect the extension to recognize steps that use backticks.

πŸ”¬ How could we reproduce it?

In a step file create a step that uses backticks

When(`I fill:`, () => {
  console.log('filling in')
});
@xeger
Copy link
Member

xeger commented Oct 6, 2022

I'm encountering this, too!

@aslakhellesoy aslakhellesoy transferred this issue from cucumber/vscode Oct 7, 2022
@aslakhellesoy
Copy link
Contributor

Partial support for template literals (I fill:) would be trivial to add. However, string interpolation cannot be supported (I ${something}).

This library parses the source code (using the tree-sitter library) to extract the step definition expressions, but it doesn’t execute or interpret the source code, which would be necessary in order to evaluate string interpolation.

We could recognise template literals without interpolation and process those, and ignore template literals with interpolation.

Are you relying on interpolation at all? And if not, why are you using template literals and not simple single/double quoted strings?

@xeger
Copy link
Member

xeger commented Oct 10, 2022

Good question! In my project, I'm using template literals because my steps frequently use both ' (in the grammatical genitive/possessive sense and " (to quote multi-word parameters). The backtick is a handy way avoid escaping one or the other. I don't use substitution in my template literals, and naturally I wouldn't expect Cucumber to help if I were to.

Your proposal to handle substitution-free literals would work ideally for me. Trying to account for them would probably just cause confusion.

P.S. thank you for providing an official VS Code plugin; both gherkin/cucumber and Code have become instrumental to my workflow.

@aslakhellesoy
Copy link
Contributor

aslakhellesoy commented Oct 10, 2022

@xeger @onthespotqa the #107 fix is released in Cucumber VSCode 1.5.0. I thought it was fine, but I'm still not seeing step definitions defined with template literals working, so I might have to reopen this. Or you could reopen this if it's not working for you either.

@xeger
Copy link
Member

xeger commented Oct 10, 2022

Confirmed that it's not working for me, either, with 1.5.0. πŸ€” I will review your PR and see if there's an obvious reason.

I lack permission to reopen this issue; will open a new one if I have anything useful to contribute in the way of troubleshooting details.

@aslakhellesoy
Copy link
Contributor

I just pushed 1.5.1 where I believe it's fixed. The fix was 001e34f.

@aslakhellesoy
Copy link
Contributor

Now did I earn some ⭐⭐⭐⭐⭐ at the marketplace? πŸ₯Ί

@xeger
Copy link
Member

xeger commented Oct 11, 2022

You've earned a lot more than that, my friend, with all of the excellent tooling you've given me over the years!

@onthespotqa
Copy link
Author

confirmed its fixed. thanks for the quick turnaround.

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

Successfully merging a pull request may close this issue.

3 participants