thenbe / neotest-playwright

A playwright adapter for neotest.
MIT License
42 stars 5 forks source link

Configuring `get_cwd` does not impact the detection of the config file and the binary #14

Closed guillaumeLamanda closed 6 months ago

guillaumeLamanda commented 1 year ago

Hi 👋

First, thanks for the work done here.

I tried to configure the neotest-playwright. I work in a monorepo, so my e2e tests are in a subfolder.
When I configured get_cwd, I expected the config and the binary detection to take the return value of cwd as the root path.

I figured out how to make it work using get_playwright_binary and get_playwright_config options, but it would be a nice to have 😄

thenbe commented 1 year ago

Hey. Thanks for the feature request. I prefer working in monorepos as well and had originally planned to implement a simple heuristic to detect and configure monorepos automatically. However, I couldn't find a straightforward way to do so (further discussion here).

At the same time, I slowly came to realize that trying to come up with a clever way to support all the possible config permutations we could encounter (typical pnpm monorepo, pnpm monorepo with a shared playwright config file in the monorepo root, repo with multiple config playwright config files, pnpm repo with a non-standard packages/* structure, etc) might be more trouble than it's worth.

So, I opted to have neotest-playwright only support the vanilla npm repo structure, and whenever it couldn't, prefer to be predictable by ceding control to the user. If the return value of get_cwd only affected (a) the location of the config playwright file and (b) the location of the playwright binary, then it would probably make sense to couple their behavior. But since get_cwd also affects where the test process is spawned, I thought it best to decouple the behavior to avoid introducing unintended consequences. Sure, it makes the setup more explicit. But in return it allows users greater flexibility, a trade-off I thought was fair.

That being said, you're spot on that, at first glance, everyone would assume that customizing get_cwd would affect the behavior of the other two. I'll update the documentation to better communicate that is not currently the case.