Home > Mobile >  Is there a shortcut in VS Code to implement a jest todo test?
Is there a shortcut in VS Code to implement a jest todo test?

Time:05-05

When I have:

test.todo('customer can order a pizza');

I would like a shortcut that would transform the line to:

test('customer can order a pizza', async () => {
  <|>
});

where <|> is the cursor position.

Is it possible using snippets? Ideally, I would prefer not to have to select the whole line before triggering the transform.

Or is there an extension that does this?

CodePudding user response:

you can use the extension multi-command

{
    "key": "alt x",
    "command": "extension.multiCommand.execute",
    "args": { 
        "sequence": [
            "cursorEnd",
            "cursorHomeSelect",
            { "command": "editor.action.insertSnippet",
              "args": {
                "snippet": "test(${TM_SELECTED_TEXT/test\\.todo('[^'] ');/'${1}'/}, async () => {\\n\\t$0\\n\\t});"
              }
            }
        ]
    }
}

CodePudding user response:

Check jest snippets to vscode https://marketplace.visualstudio.com/items?itemName=andys8.jest-snippets

CodePudding user response:

Based on answer from @rioV8, I was able to make it work

  • Related