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

feat: introduce '.todo' as toggle for JavaScript ecosystem #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ The provided commands can either be called directly via `:Specto toggle *` withi
a test block or used via keybinding.

```lua
vim.keymap.set("n", "<leader>to", "<cmd>Specto toggle only<CR>" )
vim.keymap.set("n", "<leader>ts", "<cmd>Specto toggle skip<CR>" )
vim.keymap.set("n", "<leader>to", "<cmd>Specto toggle only<CR>", { desc = "Toggle test only" })
vim.keymap.set("n", "<leader>ts", "<cmd>Specto toggle skip<CR>", { desc = "Toggle test skip" })
vim.keymap.set("n", "<leader>tt", "<cmd>Specto toggle todo<CR>", { desc = "Toggle test todo" })
```

### Scope
Expand Down Expand Up @@ -138,9 +139,10 @@ Each language can be define an individual set for `only` and `skip` features.

### Supported Languages

List of supported languages and their dedicated DSLs (eg. `it`, `describe`, `test`).
List of supported languages and their dedicated framework DSLs (eg. `it`,
`describe`, `test`).

| Language | DSL | Features | Examples |
| ------------------------- | :---: | ---------- | ------------------- |
| `javascript`/`typescript` | jest | only, skip | `it.only`,`it.skip` |
| `ruby` | rspec | skip | `xit` |
| Language | DSL | skip | only | todo |
| ------------------------- | :---------: | :--: | :--: | :--: |
| `javascript`/`typescript` | jest/vitest | ✓ | ✓ | ✓ |
| `ruby` | rspec | ✓ | ⛌ | ⛌ |
12 changes: 9 additions & 3 deletions lua/specto/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ local defaults = {
filetypes = { "javascript", "typescript" },
file_patterns = { "__tests__/", "%.?test%.", "%.?spec%." },
features = {
only = {
flag = "only",
keywords = { "it", "describe", "test" },
prefix = false,
separator = ".",
},
skip = {
flag = "skip",
keywords = { "it", "describe", "test" },
prefix = false,
separator = ".",
},
only = {
flag = "only",
keywords = { "it", "describe", "test" },
todo = {
flag = "todo",
keywords = { "it", "describe", "test", "bench" },
prefix = false,
separator = ".",
},
Expand Down
3 changes: 3 additions & 0 deletions lua/specto/toggle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ function M.only() toggle:setup("only") end
---@example it.skip() => it() => it.skip()
function M.skip() toggle:setup("skip") end

---@example it.todo() => it() => it.todo()
function M.todo() toggle:setup("todo") end

return M
2 changes: 1 addition & 1 deletion lua/specto/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
---@field prefix boolean

---@alias specto.ConfigFeatureKeywords string[]
---@alias specto.ToggleType '"only"'|'"skip"'
---@alias specto.ToggleType '"only"'|'"skip"'|'"todo"'

---@class specto.Tree
---@field type specto.ToggleType
Expand Down