From 2f4f81fcaacf8418eeff19c567231ea78b8fe77b Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 19 Feb 2025 18:14:27 +0000 Subject: [PATCH] feat(cursor): add keybindings to run tests --- keybindings.json | 61 +++++++++++++++++++++ settings.json | 138 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 198 insertions(+), 1 deletion(-) diff --git a/keybindings.json b/keybindings.json index d41d85f..18c6907 100644 --- a/keybindings.json +++ b/keybindings.json @@ -357,6 +357,67 @@ }, // // =========================================================================== + // Testing + // =========================================================================== + // + { // Run current file. + "key": "ctrl+c , v", + // "command": "testing.runCurrentFile", + "command": "macros.runTestCurrentFile", + "when": "editorTextFocus" + }, + { // Run with coverage for current file. + "key": "ctrl+c , ctrl+v", + "command": "macros.runTestCoverageCurrentFile", + "when": "editorTextFocus" + }, + { // Run at cursor. + "key": "ctrl+c , s", + "command": "macros.runTestAtCursor", + "when": "editorTextFocus" + }, + { // Run with coverage at cursor. + "key": "ctrl+c , ctrl+s", + "command": "macros.runTestCoverageAtCursor", + "when": "editorTextFocus" + }, + { // Run all tests. + "key": "ctrl+c , a", + "command": "macros.runTestAll", + "when": "editorTextFocus" + }, + { // Run with coverage for all tests. + "key": "ctrl+c , ctrl+a", + "command": "macros.runTestCoverageAll", + "when": "editorTextFocus" + }, + { // Re-run last run. + "key": "ctrl+c , l", + "command": "macros.runTestReRunLastRun", + "when": "editorTextFocus" + }, + { // Re-run with coverage for last run. + "key": "ctrl+c , ctrl+l", + "command": "macros.runTestCoverageLastRun", + "when": "editorTextFocus" + }, + { // Re-run failed tests. + "key": "ctrl+c , f", + "command": "macros.runTestReRunFailTests", + "when": "editorTextFocus" + }, + { // Debug failed tests. + "key": "ctrl+c , ctrl+f", + "command": "macros.runTestDebugFailTests", + "when": "editorTextFocus" + }, + { // Debug last run. + "key": "ctrl+c , d", + "command": "macros.runTestDebugLastRun", + "when": "editorTextFocus" + }, + // + // =========================================================================== // Documentation // =========================================================================== // diff --git a/settings.json b/settings.json index 0ffab55..b78323b 100644 --- a/settings.json +++ b/settings.json @@ -58,6 +58,12 @@ "window.commandCenter": true, // // =========================================================================== + // Testing + // =========================================================================== + // + "testing.automaticallyOpenTestResults": "neverOpen", + // + // =========================================================================== // Terminal // =========================================================================== // @@ -235,5 +241,135 @@ "svg", "typescript", "xml" - ] + ], + // + // =========================================================================== + // Macros + // =========================================================================== + // Extension URL: + // - https://marketplace.visualstudio.com/items?itemName=ctf0.macros + // + "macros.list": { + // + // Run test macros which re-focus back into the editor after being + // triggered. The test commands changes focus to the Test Results panel, and + // no settings I found avoids this. Hence these macros trigger relevant test + // running commands and then switches focus back to the editor. + // + // The 1 ms delay between the running tests and switch focus back allows for + // the Test Results panel to appear and steal focus before we try and focus + // back into the editor. Without the delay the focus commands runs before + // Test Results appear and steal focus. + // + "runTestCurrentFile": [ + "testing.runCurrentFile", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestCoverageCurrentFile": [ + "testing.coverageCurrentFile", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestAtCursor": [ + "testing.runAtCursor", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestCoverageAtCursor": [ + "testing.coverageAtCursor", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestAll": [ + "testing.runAll", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestCoverageAll": [ + "testing.coverageAll", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestReRunLastRun": [ + "testing.reRunLastRun", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestCoverageLastRun": [ + "testing.coverageLastRun", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestReRunFailTests": [ + "testing.reRunFailTests", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestDebugFailTests": [ + "testing.debugFailTests", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ], + "runTestDebugLastRun": [ + "testing.debugLastRun", + { + "command": "$delay", + "args": { + "delay": 1 + } + }, + "workbench.action.focusActiveEditorGroup" + ] + } }