You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.5 KiB

8 months ago
8 months ago
  1. return {
  2. "nvim-neotest/neotest",
  3. event = "VeryLazy",
  4. dependencies = {
  5. "nvim-lua/plenary.nvim",
  6. "nvim-treesitter/nvim-treesitter",
  7. "antoinemadec/FixCursorHold.nvim",
  8. "nvim-neotest/nvim-nio",
  9. -- Adapters
  10. "tovijaeschke/neotest-phpunit",
  11. "nvim-neotest/neotest-go",
  12. 'nvim-neotest/neotest-jest',
  13. },
  14. config = function()
  15. local neotest = require("neotest")
  16. local keymap = vim.keymap
  17. keymap.set("n", "<leader>tr", function()
  18. neotest.run.run()
  19. end, { desc = "Run neotest on current function" })
  20. keymap.set("n", "<leader>tR", function()
  21. neotest.run.run_last()
  22. end, { desc = "Run neotest on most recent test" })
  23. keymap.set("n", "<leader>tS", function()
  24. neotest.run.stop()
  25. end, { desc = "Stop running tests" })
  26. keymap.set("n", "<leader>ta", function()
  27. neotest.run.attach()
  28. end, { desc = "Attach to the currently running test" })
  29. keymap.set("n", "<leader>to", function()
  30. neotest.output.open()
  31. end, { desc = "Open the output of the test" })
  32. keymap.set("n", "<leader>ts", function()
  33. neotest.summary.toggle()
  34. end, { desc = "Toggle neotest summary pane" })
  35. vim.env.PROJECT_ROOT = vim.fn.getcwd() .. "/backend/"
  36. vim.env.ENV_PATH = vim.fn.getcwd() .. "/backend/.env"
  37. neotest.setup({
  38. adapters = {
  39. require("neotest-phpunit")({
  40. root_files = { "phpunit.xml", "composer.json" },
  41. -- phpunit_cmd = { "docker", "compose", "exec", "fpm", "./vendor/bin/phpunit" },
  42. phpunit_cmd = { "docker", "compose", "exec", "app-fpm", "./vendor/bin/phpunit" },
  43. filter_dirs = { "vendor" },
  44. mapped_docker_dir = "/var/www",
  45. append_to_cwd = "/api",
  46. }),
  47. require("neotest-go")({
  48. root = function()
  49. return './backend'
  50. end,
  51. experimental = {
  52. test_table = true,
  53. },
  54. args = { "-count=1", "-timeout=60s" },
  55. }),
  56. require('neotest-jest')({
  57. jestCommand = "npm test --",
  58. env = { CI = true },
  59. cwd = function(path)
  60. return vim.fn.getcwd()
  61. end,
  62. }),
  63. },
  64. })
  65. end,
  66. }