In order to run a single test spec file using ng test command you need to follow the following steps. Let’s say the name of your spec file is yourservice.service.spec.ts:
Go to the/src/test.ts file present in your angular project.
Replace the second last line of that file i.e replace the following code:
const context = require.context('./', true, /\.spec\.ts$/);
const context = require.context('./', true, /yourservice.service\.spec\.ts$/);
i.e we have replaced the last argument /.spec.ts$/ text with /yourservice.service.spec.ts$/
Running ng test will run that single spec file (yourservice.service.spec.ts) now.