Overview
The author transitioned from AstroVim to LazyVim and configured neotest-mocha for test running in NeoVim. The setup required careful attention to file discovery patterns.
Installation Steps
Mason Tools Installed
- bash-language-server
- eslint_d
- gitui
- js-debug-adapter
- lua-language-server
- marksman
- prettierd
- shellcheck, shfmt
- sqlfluff
- stylua
- typescript-language-server
- vtsls
Lazy Extras Loaded
- dap.core, dap.nlua
- editor.inc-rename, editor.neo-tree
- formatting.prettier
- linting.eslint
- lsp.none-ls
- test.core
- util.gitui, vscode
Configuration
A plugin configuration file was created at ~/.config/nvim/lua/plugins/neotest with neotest-mocha adapter setup. The config includes custom command arguments handling context data for test execution.
Solving “No Tests Found”
Neotest looks for files matching its discovery regex patterns like *_test.js, *.spec.js, or *.test.js. If project files follow different naming conventions, they won’t be discovered automatically.
Solution
Custom file discovery can be configured by overriding the discover_files function in adapter options to match project-specific patterns.
Additional Notes
A .mocharc.json file setup is required in the project root for proper mocha configuration.