Open Karma debug.html page on startup

前端 未结 3 1387
故里飘歌
故里飘歌 2021-01-04 11:24

The short version:

How do I start up Karma and have it open the debug.html file automatically in the same browser as the Karma start page?

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 11:39

    I found a way that makes it permanent although it is not perfect.. You can inject into the context a javascript:

    files: [
        "test/init.js",
        ...
    ]
    

    and put inside the file this code:

    (function (window) {
        if (!window.parent.initDone && window.location.pathname === '/context.html') {
             window.parent.initDone = true;
             window.open('/debug.html', '_blank');
        }
    })(window)
    

    this will ensure that the window is open only the first time the tests are run and it will be executed only in context.html.

    You can add any init code you wish inside that block.

提交回复
热议问题