Karma measure each spec elapsed time

Discussão em 'Angular' iniciado por SzymonPoltorak, Setembro 26, 2024.

  1. In this case I have an angular app and I noticed that some of the test specs are slower than others. I tried writing simple time reporter:

    function SpecTimingReporter(baseReporterDecorator, config, logger) {
    baseReporterDecorator(this);

    const log = logger.create('spec-timing-reporter');
    this.startTime = 0;

    this.onSpecStart = function (spec) {
    this.startTime = Date.now(); // Record the start time when a spec starts
    };

    this.onSpecComplete = function (browser, result) {
    const elapsedTime = Date.now() - this.startTime; // Calculate elapsed time
    log.info(`Spec "${result.description}" took ${elapsedTime} ms to complete.`);
    };
    }


    but the problem is that onSpecStart is not triggered. I searched for some documention but couldn't find anything helpful. Is there some "start" event for each spec?

    Continue reading...

Compartilhe esta Página