【发布时间】:2017-12-12 15:59:43
【问题描述】:
我在我的测试环境中使用 Karma/Mocha。我有 js 文件,它依赖于 window.location.href 来获取 url。当我使用 Karma 运行测试时,默认 url 是 www.localhost:3123/context.html。是否可以更改 url/add 参数或告诉 karma 为这个特定的测试套件使用自定义 url?
//JS file has
function populate(){
var url = new URL(window.location.href);
-- check if the url have parameter, lets say carInfo
-- if has then dispatches an event
}
//Mocha test
describe('...', function() {
it ('...', function() {
-- call populate()
-- listen if the event was triggered
})
})
【问题讨论】:
标签: javascript unit-testing mocha.js karma-runner