是否可以在 Karma 测试中读取静态 JSON 文件?我想将测试数据存储在单独的文件中。
我尝试使用 require 读取文件,但没有成功。
最佳答案
尝试使用 requirejs 的文本插件。它非常适合这个:https://github.com/requirejs/text
关于javascript - 使用 Karma 读取静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20328577/
是否可以在 Karma 测试中读取静态 JSON 文件?我想将测试数据存储在单独的文件中。
我尝试使用 require 读取文件,但没有成功。
最佳答案
尝试使用 requirejs 的文本插件。它非常适合这个:https://github.com/requirejs/text
关于javascript - 使用 Karma 读取静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20328577/
相关文章:
javascript - 如何在控制台停靠在底部而不是右侧的情况下在 Chrome 中启动测试?
javascript - 在 Gulp Karma 测试中设置调试选项
javascript - jQuery:确定一个函数是否被调用为 jQuery 事件处理程序(回调)
javascript - 如何确定我的 node.js 服务器出现 503 错误的原因?
unit-testing - 我如何测试 AngularJS 提供者?
javascript - 测试 AngularJS Controller 的初学者指南
javascript - 如何使用 Karma 单元测试运行程序捕获 console.error?
javascript - 试图理解 javascript Function.prototype