Output jasmine test results to the console

后端 未结 4 1330
野趣味
野趣味 2020-12-13 08:53


I am using Jasmine (BDD Testing Framework for JavaScript) in my firefox add-on to test the functionality of my code.

The problem is that jasmine is outputing t

4条回答
  •  离开以前
    2020-12-13 09:32

    For the sake of completeness here's the full configuration:

    First of all run the npm install command:

    npm install jasmine-console-reporter --save-dev
    

    Then check your Jasmine configuration to make sure you got the helpers setting there:

    spec/support/jasmine.json

    {
        "spec_dir": "spec",
        "spec_files": [
            "**/*[sS]pec.js"
        ],
        "helpers": [
            "helpers/**/*.js"
        ],
        "stopSpecOnExpectationFailure": false,
        "random": false
    }
    

    Since helpers are executed before specs the only thing you have to do is to create a console reporter helper.

    spec/helpers/reporter/consoleReporter.js

    const JasmineConsoleReporter = require('jasmine-console-reporter');
    
    let consoleReporter = new JasmineConsoleReporter({
        colors: 1,           // (0|false)|(1|true)|2
        cleanStack: 1,       // (0|false)|(1|true)|2|3
        verbosity: 4,        // (0|false)|1|2|(3|true)|4
        listStyle: 'indent', // "flat"|"indent"
        activity: false
    });
    
    jasmine.getEnv().addReporter(consoleReporter);
    
    • jasmine-console-reporter on npmjs.com
    • Jasmine custom reporter docs
    • Jasmine configuration reference

提交回复
热议问题