gpt4 book ai didi

javascript - 如何为不写入文件的 grunt 插件编写单元测试?

转载 作者:行者123 更新时间:2023-11-30 17:36:54 25 4
gpt4 key购买 nike

我正在创建一个 grunt 插件,它负责在文件中查找 URL 并将这些 URL 添加到 grunt 文件中使用的变量

grunt.config.set('urls', urls);

Grunt 插件的所有单元测试示例都假定该插件将写入一个文件,然后将该输出与具有“预期”结果的测试文件进行比较。

有什么方法可以测试我的 Grunt 插件是否设置了配置变量?

最佳答案

是这样的吗?

urlConfigTest: function(test) {
test.expect(1);
grunt.config.set('urls','http://foo.example.com');
test.equal(grunt.config.get('urls'), 'http://foo.example.com', 'Should set foo to the grunt configuration.');
test.done();
}

关于javascript - 如何为不写入文件的 grunt 插件编写单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21850905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com