ilife5 / life

life is a beautiful che~
4 stars 5 forks source link

karma在chrome中加载html内容两次 #26

Closed ilife5 closed 10 years ago

ilife5 commented 10 years ago

karma.conf.js中files项提供server服务,描述如官网:

The files array determines which files are included in the browser and which files are watched and served by Karma.

对html文件需要注意,如果files中按照如下写法

files: [
    "path/*.html"
]

此时在chrome中运行时将会把html文件执行,包括其中的scripts代码

ilife5 commented 10 years ago

可以参考官网对files的配置项:

included

对配置修改如下:

files: [{
    "pattern": "test/*.html",
    "included": false
 }]

即可以在控制台中观察到该html文件只加载以及执行一遍。