This extension lets you run your Karma or Angular tests in Visual Studio Code using the Test Explorer UI, and supports both the Jasmine and Mocha test frameworks. It is based on the Angular/Karma Test Explorer extension, with various significant enhancements that are outlined in Why this Extension below.
- Angular and Karma project support
- Jasmine and Mocha test framework support
- Karma version 6 support
- Support for Dev Containers
- Watch mode support with auto pass / fail test status update
- Non-Headless testing mode
- Group and run tests by folder or by test suite
- Duplicate test detection and reporting
- Specify or override environment variables for Karma
- Run your tests in VS Code using any custom launcher in the Karma config file
- Auto-reload Karma when karma config or other files change
- Automatic port management prevents any port conflicts when running tests
- Support for using a custom Karma executable or script (enables greater automation and integration with other processes and workflows)
- Config option to easily switch Karma server to debug logging
- Shows your Karma tests in a visual test explorer in VS Code
- Adds code lenses to your test files to easily run individual tests or suites
- Adds gutter decorations to your test files that show the status of each test
- Adds line decorations to your test files that show the failure message at the point of each test failure
Karma Test Explorer uses reasonable defaults that in many cases means it will work out-of-the-box without any configuration. Nonetheless, specific configuration to the particular needs of your project can often bring additional performance, usability and features that increase the productivity and value of the extension to you and your team.
To quickly get started:
- Ensure the required dependencies are installed - Chrome browser on the computer or container, and the project dependencies (such as Karma, Angular, Jasmine, Mocha, etc)
- Install the Karma Test Explorer extension
- If the project root path is not same as the VS Code workspace root, specify its path using the
karmaTestExplorer.projectRootPath
setting - If the
karma.conf.js
file is not at the project root folder, specify its path using thekarmaTestExplorer.karmaConfFilePath
setting - Specify your project's test files using the
karmaTestExplorer.testFiles
setting - Apply the updated settings and wait a moment while it refreshes, or simply restart VS Code
- When done, you should see your tests in the Test View, and code lenses above each test in the editor, either of which can be used to run and debug the tests
Also explore the many other extension settings to further customize it to the needs of your project and team, and if you run into any issues with setup or usage, please see the more detailed Documentation for help.
For a more detailed guide on how to setup Karma Test Explorer to work with your project, customizing and fully leveraging all its features, and other helpful documentation around common scenarios and potential issues, please see the more detailed Documentation.
The Karma Test Explorer extension was initially created out of need for additional features from the Angular/Karma Test Explorer extension at a time when that project seemed not to be accepting contributions anymore, and is a major rewrite aimed at facilitating various significant enhancements and new features (such as some of those in the initial release changelog).
This extension's core focus is on better and robust support for:
- Large projects with thousands of tests
- Remote development sceanarios with Dev Containers
- Flexibility to support a wide range of testing scenarios and workflows
- Reliability, usability, and team productivity
Special thanks to the author and contributors of the Angular/Karma Test Explorer extension on which Karma Test Explorer is based.
If you encounter any problems using Karma Test Explorer, would like to request a feature, or have any questions, please open an issue here.
If you like the Karma Test Explorer extension, please consider rating it in the marketplace, and starring the GitHub repo.