{"id":21013415,"url":"https://github.com/heavenshell/vim-quickrun-hook-unittest","last_synced_at":"2025-12-28T00:20:15.218Z","repository":{"id":3617810,"uuid":"4683322","full_name":"heavenshell/vim-quickrun-hook-unittest","owner":"heavenshell","description":"Quickrun hook for enable to unittest by selecting method.","archived":false,"fork":false,"pushed_at":"2023-10-30T01:40:35.000Z","size":11236,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-06T02:12:12.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heavenshell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-06-16T08:37:14.000Z","updated_at":"2024-06-28T08:23:59.000Z","dependencies_parsed_at":"2024-11-19T09:46:54.721Z","dependency_job_id":"43f87a91-3c2c-433c-9b50-4c18e933564d","html_url":"https://github.com/heavenshell/vim-quickrun-hook-unittest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heavenshell%2Fvim-quickrun-hook-unittest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heavenshell%2Fvim-quickrun-hook-unittest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heavenshell%2Fvim-quickrun-hook-unittest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heavenshell%2Fvim-quickrun-hook-unittest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heavenshell","download_url":"https://codeload.github.com/heavenshell/vim-quickrun-hook-unittest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243437970,"owners_count":20290865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T09:42:20.873Z","updated_at":"2025-12-28T00:20:15.178Z","avatar_url":"https://github.com/heavenshell.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quickrun hook for unittest\n\nQuickRun hook for enable to unittest by selecting method.\n\nFor example.\n\n```python\nfrom unittest import TestCase\n\nclass TestFoo(TestCase):\n    def test_foo(self):\n        pass\n\n    def test_bar(TestCase):\n        pass\n```\n\nQuickRun execute all tests.\nBut if you want to run only `test_bar()` method.\n\n## Example\n\n### Python\n\n![Python](./assets/python.gif)\n\n### Jest\n\n![Jest](./assets/jest.gif)\n\n## Install\n\nInstall the distributed files into Vim runtime directory which is usually\n~/.vim/, or $HOME/vimfiles on Windows.\n\nIf you install pathogen provided by Tim Pope, you should extract the\nfile into 'bundle' directory.\n\n## Usage\n\n1. Add below example to your `.vimrc` or `_vimrc`.\n\n  ```vim\n  nnoremap \u003csilent\u003e ,r :QuickRun -mode n -runner job -hook/unittest/enable 1\u003cCR\u003e\n  ```\n\n2. Open your unittest file.\n3. Move cursor to test method scope.\n4. For example, move cursor next to def test_foo(self) line.\n5. Type `,r` and then execute QuickRun automatically.\n6. QuickRun output only test_foo() test result.\n\n## Test runners\n\nThis plugin required awesome testing framework/runner to run.\n\n- Python\n  - [nose(Python unittesting framework)](http://nose.readthedocs.org/en/latest/)\n  - [py.test(Python unittesting framework)](http://pytest.org/latest/index.html)\n  - [Django](https://docs.djangoproject.com/en/dev/topics/testing/overview/#running-tests)\n- PHP\n  - [Stagehand_TestRunner:PHP continuous test runner](http://piece-framework.com/projects/stagehand-testrunner/wiki)\n- Ruby\n  - [RSpec: Ruby testing tool for Behaviour-Driven Development](http://rspec.info/)\n  - [minitest/unit: a small and incredibly fast unit testing framework](https://github.com/seattlerb/minitest)\n- JavaScript / TypeScript\n  - [Mocha - the fun, simple, flexible JavaScript test framework](https://mochajs.org)\n  - [Jest - Delightful JavaScript Testing](http://facebook.github.io/jest/)\n  - [vitest - Next generation testing framework powered by Vite](https://vitest.dev/)\n  - [Deno](https://deno.land/manual/testing)\n- Rust(`cargo test`)\n  - [Rust - Rust Programming Language](https://doc.rust-lang.org/stable/rust-by-example/testing.html)\n\n## Example Quickrun configs(recommend)\n\n```vim\nlet g:quickrun_unittest_config = {\n  \\ 'typescript': {\n  \\   '.spec.ts\\%[x]': {  \" *.spec.ts or *.spec.tsx run jest\n  \\     'ft': 'typescript.jest',\n  \\     'config': {'command': 'jest'},\n  \\   },\n  \\   'test.ts\\%[x]': {  \" *_test.ts or *_test.tsx run Deno's test\n  \\     'ft': 'typescript.deno',\n  \\     'config': {'command': 'deno'},\n  \\   },\n  \\   '.spec.js': {      \" *.spec.js run mocha\n  \\     'ft': 'typescript.mocha',\n  \\     'config': {'command': 'mocha'},\n  \\   },\n  \\ },\n  \\ 'python': {\n  \\   'test_[A-z0-9_.]*.py': {\n  \\     'ft': 'python.unit',\n  \\     'config': {'command': 'nosetests', 'cmdopt': '-v -s -d'},\n  \\   },\n  \\   'tests.py': {\n  \\     'ft': 'python.unit',\n  \\     'config': {'command': 'nosetests', 'cmdopt': '-v -s -d'},\n  \\   },\n  \\ },\n  \\ 'php': {\n  \\   'test.php': {\n  \\     'ft': 'php.unit',\n  \\     'config': {'command': 'testrunner', 'cmdopt': 'phpunit'},\n  \\   },\n  \\ },\n  \\ 'perl': {\n  \\   '.t': {\n  \\     'ft': 'perl.unit',\n  \\     'config': {'command': 'prove'},\n  \\   },\n  \\ },\n  \\ 'ruby': {\n  \\   '_spec.rb': {\n  \\     'ft': 'ruby.rspec',\n  \\     'config': {'command': 'rspec', 'cmdopt': '-f d'},\n  \\   },\n  \\ },\n  \\ 'go': {\n  \\   '_test.go': {\n  \\     'ft': 'go.test',\n  \\     'config': {'command': 'go', 'cmdopt': 'test -v', 'exec': ['%c %o %a'] },\n  \\   },\n  \\ }}\n\n\n\" You can describe like followings\nlet config = {\n  \\ 'ft': 'python.django',\n  \\ 'config': {\n  \\   'command': 'python',\n  \\   'cmdopt': 'test -v 2 --keepdb',\n  \\   'root': 1,\n  \\   'test_fw': 'unittest',\n  \\ }}\nlet g:quickrun_unittest_config['python'] = {\n  \\ 'test_[A-z0-9_.]*.py': config,\n  \\ 'tests.py': config,\n  \\ }\n```\n\n- Key of g:quickrun_unittest_config is filetype\n- Key of filetype is file name pattern\n- Value of ft is Quickrun unittest's file name\n- Value of config is Quickrun's command\n\n## Example QuickRun configs(multiple filetypes)\n\n```vim\naugroup QuickRunUnitTest\n  autocmd!\n  autocmd BufWinEnter,BufNewFile *test.php setlocal filetype=php.unit\n  \" Choose UnitTest, py.test or Django.\n  autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.unit\n  \" autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.pytest\n  \" autocmd BufWinEnter,BufNewFile test_*.py setlocal filetype=python.django\n  autocmd BufWinEnter,BufNewFile *.t       setlocal filetype=perl.unit\n  autocmd BufWinEnter,BufNewFile *_spec.rb setlocal filetype=ruby.rspec\n  autocmd BufWinEnter,BufNewFile *_test.rb setlocal filetype=ruby.minitest\n  autocmd BufWinEnter,BufNewFile *_test.go setlocal filetype=go.test\n  \" TypeScript support only Jest\n  autocmd BufWinEnter,BufNewFile *.spec.ts setlocal filetype=typescript.jest\n  \" Choose Mocha or Jest\n  \" autocmd BufWinEnter,BufNewFile *.test.js setlocal filetype=javascript.mocha\n  \" autocmd BufWinEnter,BufNewFile *.test.js setlocal filetype=javascript.jest\n  autocmd BufWinEnter,BufNewFile *test.ts setlocal filetype=typescript.deno\n  autocmd BufWinEnter,BufNewFile *test.tsx setlocal filetype=typescript.deno\naugroup END\nlet g:quickrun_config = {}\nlet g:quickrun_config['php.unit']         = { 'command': 'testrunner', 'cmdopt': 'phpunit' }\nlet g:quickrun_config['python.unit']      = { 'command': 'nosetests',  'cmdopt': '-v -s'   }\nlet g:quickrun_config['python.pytest']    = { 'command': 'py.test',    'cmdopt': '-v'      }\n\" Django unittest\nlet g:quickrun_config['python.django']    = { 'command': 'python',     'cmdopt': 'test --pararell=2 --keepdb -v2'}\n\" pytest-django\n\" let g:quickrun_config['python.django']    = { 'command': 'python',     'cmdopt': 'test --noinput -- --verbose --reuse-db', 'test_fw': 'pytest' }\nlet g:quickrun_config['ruby.rspec']       = { 'command': 'rspec',      'cmdopt': '-f d'    }\nlet g:quickrun_config['ruby.minitest']    = { 'command': 'ruby'                            }\nlet g:quickrun_config['go.test']          = { 'command': 'go',         'cmdopt': 'test -v' }\nlet g:quickrun_config['typescript.jest']  = { 'command': 'jest'  }\nlet g:quickrun_config['javascript.mocha'] = { 'command': 'mocha' }\nlet g:quickrun_config['javascript.jest']  = { 'command': 'jest'  }\n```\n\n### Extra config\n\nIf you using jest in monorepo(lerna) and enable autochdir, you can set jest.config.\n\n```vim\nlet g:quickrun_hook_unittest_enable_jest_config = 1\n\" If you don't set below path, default jest.config.json was used.\nlet g:quickrun_hook_unittest_jest_config_path = '/path/to/jest.config.json\n```\n\nSince Jest v27, default testEnvironment was changed from `jsdom` to `node`.\nQuickRunUnitTest keep backward compatible with previous behaviour as `jsdom`.\n\nIf you want change to node, you can set like following.\n\n```vim\nlet g:quickrun_hook_unittest_jest_test_environment = 'node'\n```\n\nThis option is affect only jest in monorepo(lerna) and enable autochdir.\n\n## LICENSE\n\nzlib License(Same as vim-quickrun)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheavenshell%2Fvim-quickrun-hook-unittest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheavenshell%2Fvim-quickrun-hook-unittest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheavenshell%2Fvim-quickrun-hook-unittest/lists"}