如何在Intern测试中模拟依赖项 [英] How to mock dependencies in Intern tests

查看:101
本文介绍了如何在Intern测试中模拟依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实习生是否使用requireJs加载测试?我正在使用这种方法模拟出我要测试的模块的依赖关系,所以我想知道这是否也适用于Intern.

Is intern use requireJs to load the test? I'm using this approach to mock out dependencies for the module I wanna test, so I wonder if this will work with Intern as well.

推荐答案

实习生使用Dojo Toolkit的AMD加载器.要模拟依赖关系,您应该只能使用标准的AMD map功能.在您的Intern配置文件中,应该执行以下操作:

Intern uses the Dojo Toolkit’s AMD loader. To mock out dependencies, you should be able to just use the standard AMD map feature. In your Intern configuration file, something like this should do what you need:

define({
  …,
  loader: {
    map: {
      myPackage: {
        'myPackage/foo': 'myPackage/mocks/foo',
        'herp': 'myPackage/mocks/herp',
        'derp': 'myPackage/mocks/derp'
      }
    }
  }
});

请参见 https://github.com/amdjs/amdjs-api/wiki/Common -Config#map- 有关map的更多信息.

See https://github.com/amdjs/amdjs-api/wiki/Common-Config#map- for more information on map.

这篇关于如何在Intern测试中模拟依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆