This extension adds language support for the Bats (Bash Automated Testing System) testing framework to VS Code.
- Bats language support for VSCode
- Syntax highlighting for core functions
- Syntax highlighting for community modules
- Code Snippets for quick coding for core functions
- Code Snippets for quick coding for community modules
Bash Automated Testing System (2021) is a community-maintained Bats project.
(c) 2011-2016 Sam Stephenson
(c) 2017-2021 bats-core organization
Bats is a TAP-compliant testing framework for Bash. It provides a simple way to verify that the UNIX programs you write behave as expected.
A .bats
test file is a Bash script with special syntax for defining test cases. Under the hood, each test case is just a function with a description.
See bats-core README for documentation on how to use Bats.
Project | version | code snippets | syntax highlighting |
---|---|---|---|
https://github.com/bats-core/bats-core | |||
https://github.com/bats-core/bats-assert | |||
https://github.com/bats-core/bats-support | |||
https://github.com/bats-core/bats-file | |||
https://github.com/lox/bats-mock |
These modules have snippets:
- https://github.com/bats-core/bats-core
- https://github.com/bats-core/bats-assert
- https://github.com/bats-core/bats-support
- https://github.com/bats-core/bats-file
- https://github.com/lox/bats-mock
Type BATS:*snippet*
to use snippets.
- BATS:env : shebang.
- BATS:setup : Setup function.
- BATS:teardown : Teardown function.
- BATS:load : Load common code.
- BATS:bats_load_library : Load system-wide libraries.
- BATS:test : Test case.
- BATS:status : Test status code.
- BATS:output : Test output.
- BATS:line : Test line output.
- BATS:skip : Skip test.
- BATS:assert
- BATS:assert_output
- BATS:assert_line
- BATS:assert_success
- BATS:assert_failure
- BATS:assert_equal
- BATS:assert_not_equal
- BATS:refute
- BATS:refute_output
- BATS:refute_line
These modules have syntax highlighting support:
- https://github.com/bats-core/bats-core
- https://github.com/bats-core/bats-assert
- https://github.com/bats-core/bats-support
- https://github.com/bats-core/bats-file
- https://github.com/lox/bats-mock
If you want Bats
syntax highlighting to look different to shellscript
syntax, you can change your user preferences or workspace settings (.vscode/settings.json
).
Default theme, for shellscript
:
Example after saving the editor.tokenColorCustomizations
settings below.
Add this to your VS Code settings.
{
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "keyword.control.bats",
"settings": {
"foreground": "#9f1fd1",
"fontStyle": "italic"
}
},
{
"scope": "support.function.bats",
"settings": {
"foreground": "#d41515",
"fontStyle": "italic"
}
},
{
"scope": "support.variable.bats",
"settings": {
"foreground": "#329432",
"fontStyle": "italic"
}
}
]
}
}
This extension is published in the VSCode marketplace.
- Run Install Extensions from the Command Palette
- Search and choose
bats
.
See Changelog.
Feel free to report any issues.
If you like Bats, you may also like ShellCheck and the VSCode extension
This extension was inspired by sublime-bats.