Javascript Proxyquire显示错误“;找不到模块";
我正试图用一个私有函数替换Meteor应用程序中的测试 流星1.6.1 流星测试:mocha@1.1.2 在my parentFunction.js中:Javascript Proxyquire显示错误“;找不到模块";,javascript,testing,meteor,mocha.js,proxyquire,Javascript,Testing,Meteor,Mocha.js,Proxyquire,我正试图用一个私有函数替换Meteor应用程序中的测试 流星1.6.1 流星测试:mocha@1.1.2 在my parentFunction.js中: import { some function } from 'anotherFile'; function childFunction() { ... return someValue; } export default function parentFunction() { return childFunction() }
import { some function } from 'anotherFile';
function childFunction() {
...
return someValue;
}
export default function parentFunction() {
return childFunction()
}
在我的测试文件中:
const proxyquire = require('proxyquire');
if (Meteor.isServer) {
...
describe('parentFunction', () => {
it('uses the mocked child function', () => {
const testThing = proxyquire('./parentFunction', {
'childFunction': () => ({ 'name': 'bob' }),
});
});
}
parentFunction.js与我的测试文件位于同一个文件夹中,为了再次检查路径,我确保了这一点:
import parentFunction from './parentFunction';
但是当我运行测试时,我看到一个错误:
Error: Cannot find module './parentFunction.js'
我做错了什么?我尝试了一条绝对路径,但没有成功。从文档中我可以看到,文件中需要proxiquire的相对路径应该可以
谢谢你的帮助