I use karma for run tests. I have many tests and run all tests is very slow process. I want to run only single test in order to spend less time, because all test runs about
I know two ways:
The easiest way is to use the vscode-test-explorer extension along with its child angular-karma-test-explorer and jasmine-test-adapter, you'll get a list of current test to run one by one if you want:
For me, i wasn't able to use the extension way because of this bug, and so i ended up modifying the test.ts
file (as stated here by Shashi), just to consolidate that answer here, by default context looks like this:
const context = require.context('./', true, /\.spec\.ts$/);
You should modify it's RegExp to match the files that you'r willing to test, for example if you want to test a single file named "my.single.file.custom.name.spec.ts" it'll look this way:
const context = require.context('./', true, /my\.single\.file\.custom\.name\.spec\.ts$/);
For more details about require
parameters you may find it here at their wiki.
Currently there's an open issue to improve their current behaviour, you can follow their progress at their github page (https://github.com/karma-runner/karma/issues/1507).