Test Failure Sound
Play a sound when VS Code test tasks fail. Built for task-based workflows and monorepos.
Features
- Detects non-zero exit codes from test tasks
- Plays a bundled default sound or a custom audio file
- Commands for running all tests, current-file tests, and watch mode
- Monorepo-aware current-file testing (Yarn workspaces)
- Cross-platform audio playback (macOS, Windows, Linux)
Installation
Local development
- Install dependencies:
npm install
- Build:
npm run compile
- Press
F5 to launch an Extension Development Host
Package and install
- Install
vsce: npm install -g @vscode/vsce
- Package:
vsce package
- Install the
.vsix from the VS Code Extensions view (Install from VSIX)
Usage
Use the command palette to run tasks:
- Test Failure Sound: Run Yarn Tests
- Test Failure Sound: Run Tests for Current File
- Test Failure Sound: Toggle Watch Mode
- Test Failure Sound: Select Sound File
The extension listens to task completion and plays a sound when a test task exits with a non-zero code.
Keyboard shortcuts
- Run Yarn Tests: Ctrl+Alt+Shift+T (Cmd+Option+Shift+T on macOS)
- Run Tests for Current File: Ctrl+Alt+Shift+F (Cmd+Option+Shift+F on macOS)
- Toggle Watch Mode: Ctrl+Alt+Shift+W (Cmd+Option+Shift+W on macOS)
- Select Sound File: Ctrl+Alt+Shift+S (Cmd+Option+Shift+S on macOS)
Configuration
| Setting |
Type |
Default |
Description |
testFailureSound.enabled |
boolean |
true |
Enable or disable sound playback |
testFailureSound.soundFilePath |
string |
"" |
Absolute path to custom sound file; empty uses bundled fahhh.mp3 (or set via command) |
testFailureSound.testCommand |
string |
"yarn test" |
Command to run all tests |
testFailureSound.testFileCommand |
string |
"npx jest {{file}}" |
Command to run a single test file; {{file}} is replaced |
testFailureSound.volume |
number |
0.5 |
Volume (0.0 to 1.0). Some players may ignore this |
Current-file tests and coverage
When you use the default testFailureSound.testFileCommand, the extension automatically adds --coverage=false to avoid global coverage thresholds failing on single-file runs.
Monorepo support
If a monorepo is detected, the extension searches upward from the test file for the nearest package.json with a name and uses it as the Yarn workspace name. For example:
yarn workspace <workspace-name> test {{file}} --coverage=false
If no workspace name is found, it falls back to yarn test {{file}} --coverage=false from the repo root.
- macOS: mp3, wav, aiff, m4a (via
afplay)
- Windows: wav (via PowerShell
Media.SoundPlayer)
- Linux: wav, mp3 (via
paplay, aplay, or ffplay)
Limitations
- Only task execution is observed. Running tests directly in the terminal is not detectable by VS Code extensions.
- Task names should include keywords like
test, jest, vitest, mocha, or spec to be recognized as test tasks.
Troubleshooting
No sound on failures
- Check the Output panel: View -> Output -> Test Failure Sound
- Verify the sound file path exists (absolute path)
- Test playback directly:
- macOS:
afplay /path/to/sound.wav
- Linux:
paplay /path/to/sound.wav
- Windows: open the file in a media player
Current-file tests fail to run
- Confirm the file is inside a workspace folder
- Check the detected command in the Output panel
- Set
testFailureSound.testFileCommand explicitly if your repo requires a custom test runner
Example settings
{
"testFailureSound.enabled": true,
"testFailureSound.soundFilePath": "/Users/you/sounds/fail.wav",
"testFailureSound.testCommand": "yarn test",
"testFailureSound.testFileCommand": "yarn test -- --testPathPattern={{file}}",
"testFailureSound.volume": 0.7
}
License
MIT