Reputation: 564
How to make ng test --browsers=ChromeHeadless
to display the description in describe()
and it()
of a spec.ts file?
e.g.:
ng test --include=src/app/interval/interval.spec.ts
display this in the Chrome browser:
finished in 0.039s
1 spec, 0 failures, randomized with seed 41004
interval
should emit every millisecond
where:
interval
should emit every millisecond
come from the description in "describe()" and "it()" in my interval.spec.ts:
import { interval } from 'rxjs';
import { testScheduler } from '../test_scheduler';
import { take } from 'rxjs/operators';
describe('interval', () => {
it('should emit every millisecond', () => {
testScheduler.run((helpers) => {
const { expectObservable } = helpers;
const numbers$ = interval(1).pipe(take(2));
expectObservable(numbers$).toBe('-0(1|)', {'0': 0, '1': 1});
});
});
});
However, my desired output is:
interval
should emit every millisecond
Do not appear when running:
ng test --browsers=ChromeHeadless --no-watch --progress --include=src/app/interval/interval.spec.ts
Actual output:
✔ Browser application bundle generation complete.
29 12 2023 07:33:28.830:INFO [karma-server]: Karma v6.4.2 server started at http://localhost:9876/
29 12 2023 07:33:28.833:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
29 12 2023 07:33:28.842:INFO [launcher]: Starting browser ChromeHeadless
29 12 2023 07:33:29.577:INFO [Chrome Headless 117.0.5938.132 (Linux x86_64)]: Connected on socket LwJzp9zIOKI1y83KAAAB with id 33092643
Chrome Headless 117.0.5938.132 (Linux x86_64): Executed 1 of 1 SUCCESS (0.002 secs / 0.01 secs)
TOTAL: 1 SUCCESS
versions: "@angular/cli": "^17.0.8", "jasmine-core": "~5.1.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.2.0", "karma-jasmine": "~5.1.0"
Upvotes: 0
Views: 118
Reputation: 26180
You need the karma-jasmine-html-reporter plugin.
First install it using npm
npm install karma-jasmine-html-reporter --save-dev
Then define it inside karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-jasmine-html-reporter')
],
...
Upvotes: 0