quolpr / quicktest.nvim

Run your tests in split window or popup with live feedback
MIT License
66 stars 5 forks source link

Feature: Make `is_enabled` configurable #16

Closed flunderpero closed 1 month ago

flunderpero commented 1 month ago

I have a project that has both, Playwright and vitest tests. With the added Playwright adapter (#15), I now need to be able to decide whether the vitest or the Playwright adapter should run a test file.

I don't think that there is a universal way to distinguish vitest from Playwright files, so it cannot be done in the adapter's is_enabled function, but has to be configurable by the user. In my case I would then use a TreeSitter query to see if the Playwright test function is imported (`import {test} from "@playwright/test"). Others might want to look at the filename.

quolpr commented 1 month ago

@flunderpero will such API:

require("quicktest.adapters.vitest")({
  is_enabled = function(bufnr) return true end
})

work for you?

flunderpero commented 1 month ago

Yes, that's exactly what's needed.

quolpr commented 1 month ago

@flunderpero added to adapters, readme is updated with examples. Thanks for an idea!