在testing中configuration一个单独的Grunt实例

我一直在写一个小的咕噜插件,现在我被卡住了试图端到端的插件testing。 我想完成的是这个

  • 编写一个testing用例,为我的插件configuration一个最小的gruntconfiguration的grunt实例,并运行该任务
  • testing生成的文件是否等于预期的输出
  • 运行grunt nodeunit时自动运行该testing

到目前为止,我似乎一直在configuration一个单独的Grunt实例,因为新实例似乎与已经加载的Grunt实例共享configuration。

在我的plugin_test.js有这样的东西

 var testGrunt = require('grunt'); exports.codekit = { setUp: function(done) { testGrunt.initConfig({ myPlugin : { // the config } }); testGrunt.task.run(['myPlugin']); done(); }, basic_parsing_works: function(test) { test.expect(1); // no idea what this does test.equal(1,1,'basic test'); //var actual = testGrunt.file.read('tmp/test01_result.html'); //var expected = testGrunt.file.read('expected/test01_expected.html'); //test.equal(actual, expected, 'should parse file.'); test.done(); } }; 

问题是当我运行myPlugin的任务时,它使用在“外部”(已经运行)的Grunt实例中加载的configuration。 即使我已经专门创build了一个新的Grunt实例( testGrunt )。

有没有办法避免这种情况?