在Babel7中,我们有babel.config.js文件。这个文件的路径可以通过configFile或config-file参数传递,就像我在互联网上看到的那样。然而,我不能让摩卡和大口摩卡读babel.config.js。
这是我运行mocha的方式:
./node_modules/.bin/mocha ./foo.spec.js --compilers js:@babel/register这就是我运行gulpMocha的方式
pipe(gulpMocha({
reporter: 'spec',
require: [
'@babel/preset-env',
]
}))如何将Babel7配置文件路径传递给mocha和gulp-mocha?
如果他们两个都不可能,那么,至少对一个人来说。
发布于 2019-02-15 01:26:45
建议的解决方案是here。例如,如果项目结构是这样的:
Project
|-module1
|-module2
|-babel.config.js我们想测试一下module1。我们在Project/module1中创建包含以下内容的register.js文件:
require("@babel/register")({
rootMode: "upward"
});在此之后,在Project/module1中,我们这样运行mocha : babel将找到mocha --require register.js和babel.config.js。
https://stackoverflow.com/questions/54669222
复制相似问题