Electron 项目中的 Mocha 测试。为什么需要 Babel?
Mocha testing in Electron project. Why is Babel needed?
我有 Electron 项目,想实现单元测试。我安装了 mocha
和 chai
,但由于 import
关键字,它们无法 运行。我想知道为什么,因为我读到 Electron 在大多数情况下确实支持 ES6 甚至 ES7。
这是我的依赖项:
"dependencies": {
"bootstrap": "^4.3.1",
"chai": "^4.2.0",
"mocha": "^6.2.2",
"react": "^16.9.0",
"react-bootstrap": "^1.0.0-beta.12",
"react-bootstrap-table-next": "^3.2.1",
"react-dom": "^16.9.0",
"react-scripts": "3.1.1",
"react-splitter-layout": "^4.0.0"
},
Mocha 和 Chai 是 devDependency
。它不是电子上的运行。当你为 Electron 打包库时。只有依赖项将 运行 捆绑到 electron 中,而不是 devDependencies
。所以当 运行ning mocha, chai 测试你需要 babel 来支持 es6 语法。
我有 Electron 项目,想实现单元测试。我安装了 mocha
和 chai
,但由于 import
关键字,它们无法 运行。我想知道为什么,因为我读到 Electron 在大多数情况下确实支持 ES6 甚至 ES7。
这是我的依赖项:
"dependencies": {
"bootstrap": "^4.3.1",
"chai": "^4.2.0",
"mocha": "^6.2.2",
"react": "^16.9.0",
"react-bootstrap": "^1.0.0-beta.12",
"react-bootstrap-table-next": "^3.2.1",
"react-dom": "^16.9.0",
"react-scripts": "3.1.1",
"react-splitter-layout": "^4.0.0"
},
Mocha 和 Chai 是 devDependency
。它不是电子上的运行。当你为 Electron 打包库时。只有依赖项将 运行 捆绑到 electron 中,而不是 devDependencies
。所以当 运行ning mocha, chai 测试你需要 babel 来支持 es6 语法。