【发布时间】:2017-12-13 15:00:56
【问题描述】:
我正在为我的测试堆栈使用 karma/mocha/chrome headless。
--js 1
document.addEventListener('test', ...);
do sth more.
--js 2
document.addEventListener('test', ...);
do sth more differently.
-- test suite 1
require(test1)
i am dispatching the test event here to test js 1
-- test suite 2
require(test2)
I am dispatchinh the test event here to test js 2
问题是这两个文件现在都将在全球范围内可用。当我运行测试套件 2 时,js1 和 js2 事件都会监听我的调度,因为 js1 仍然是全局可用的。
我的完美场景是。将 js1 加载到测试套件 1 并将其封装在那里。在运行测试后,Hacky 方法将删除它。
我的问题是,如何确保所需的 js 文件在一个测试套件的范围内本地加载?基本上只加载特定测试套件的必要文件,并将它们与其他测试套件隔离。
谢谢。
【问题讨论】:
标签: javascript requirejs mocha.js karma-runner google-chrome-headless