/vscode-open-spec-file

Visual Studio Code extension to quickly open the relevant .spec.js file

Primary LanguageJavaScript

VSCode Open Spec File

A Visual Studio Code extension to simplify your TDD workflow by creating and opening the .spec file next to the source with one command.

Purpose

The extension will create an empty file next to the current one with the existing base name plus the suffix .spec (configurable). If you're editing /home/You/module.js and run the Open Spec File command VSCode will open /home/You/module.spec.js in the second column (so you can work on the source and spec side-by-side). You can set up a "reverse" matching, for example to open a .html file based on a .css file.

Open Spec File demonstration

Usage

You can use the Command Palette: > Open Spec File, or the default key binding: ⌘+K ⌘+K / CTRL-K CTRL-K

Configuration

Using VS Code's preferences, you can set the map of suffixes:

"openSpecFile.suffixMap": {
    ".js": ".spec.js",
    ".html": ".css",
    ".css": ".html",
}

The mapping is one-way only, meaning you need to set up "reverse" pairs manually if you want to go from extension1 to extension2 and vice versa.

openSpecFile.openInNewColumn determines if the related file opens in a new column

Icon by Freepik CC 3.0 BY