How to mock dependencies in Intern tests [closed]

两盒软妹~` 提交于 2019-11-29 16:34:53

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'
      }
    }
  }
});

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

Not sure if this would be helpful. I've created a module for mocking module dependencies using the Dojo loader: https://github.com/stdavis/StubModule

Works well for my needs. I don't see any reason why it wouldn't work in intern but haven't tried it yet.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!