1
我的任務是對大型網站上已有的一些JavaScript實施Mocha測試。這個網站有一個全局命名空間對象來保存它的所有功能和常見變量,以及在同一個對象中設置的每個頁面,並且我試圖用Mocha來識別這個,但我似乎不能。全球JavaScript命名空間和摩卡
例如:
//global namespace declaration in the common.js file
var ns = {};
ns.commonValue = 1;
ns.commonFunc = function() {};
//extension of the namespace on an individual page
ns.thisPage = {};
ns.thisPage.pageVal = 1;
當測試單個頁面的JavaScript,ns是不確定的。
任何幫助都會很好。提前