vitalets / playwright-bdd

BDD testing with Playwright runner
https://vitalets.github.io/playwright-bdd/
MIT License
300 stars 35 forks source link

Question: Is it possible to get feature name and line number in console error and report? #181

Open viktor-silakov opened 3 months ago

viktor-silakov commented 3 months ago
image

It would be very nice to have such an opportunity to go to the desired location of the error using a mouse click in the console, now there is a link only to the compiled js, which is better than nothing, but I would also like to have the ability to quickly go to the desired step using path like ./features/test.featute:123 this would greatly improve the dev experience

viktor-silakov commented 2 months ago

Are there any workarounds available for this functionality? Additionally, are there any plans to implement this feature in the near future? If so, I would be happy to contribute and assist in its development if needed.

vitalets commented 2 months ago

Hi @viktor-silakov ! Yes, I will up priority on that. Btw, what reporter do you primary use?

Currently, there is a workaround how to get original location of scenario. There are 2 undocumented fixtures: $uri and $bddTestMeta. Example:

Given("I am on Playwright home page", async ({ page, $uri, $bddTestMeta }) => {
  console.log($uri, $bddTestMeta);
});

Output:

features/homepage.feature { pickleLocation: '3:5' }
viktor-silakov commented 2 months ago

Thanks for the workaround and the response. Currently, I am using a standard HTML reporter for now, but my issue is more related to console errors.

By the way, have you ever considered creating a community chat, for example, on Gitter or Discord? There are some questions that might not be suitable for the GitHub issues format, and a chat could be really helpful.

vitalets commented 2 months ago

Thanks for the workaround and the response.

I'm investigating how to implement it natively. But looks like we need to patch Playwright on some level, to change test location in error output.

I've noticed that for regular Playwright tests output paths are also non-navigatebale by click. For example, if I have e2e/sample.spec.ts, then error output will contain only sample.spec.ts, not e2e/sample.spec.ts. Is it same for you?

By the way, have you ever considered creating a community chat, for example, on Gitter or Discord? There are some questions that might not be suitable for the GitHub issues format, and a chat could be really helpful.

That's good idea! Done. You are welcome to join: https://github.com/vitalets/playwright-bdd?tab=readme-ov-file#community

Note: and big thanks for your support ❤️