[英]Babel not preprocessing files
I having trouble configuring my karma.conf.js file to do unit test on ES6 via Webstorm, using babel and Karma.我无法使用 babel 和 Karma 配置我的 karma.conf.js 文件以通过 Webstorm 在 ES6 上进行单元测试。
What I am trying to do here is to run the test on '/test/BaseElement.test.js'
When launching the test, i am receiving the following error:我在这里尝试做的是在
'/test/BaseElement.test.js'
上运行测试启动测试时,我收到以下错误:
An error was thrown in afterAll
Uncaught SyntaxError: Unexpected token 'export'
SyntaxError: Unexpected token 'export'
Which means to me that the preprocessing has not properly been done.这对我来说意味着预处理没有正确完成。
Here are my dependancies from my package.json:这是我的 package.json 的依赖项:
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.9.5",
"@webcomponents/webcomponentsjs": "^2.4.3",
"jasmine": "^3.5.0",
"jspm": "^2.0.0-beta.7",
"karma": "^5.0.1",
"karma-babel-preprocessor": "^8.0.1",
"karma-chrome-launcher": "^3.1.0",
"karma-jasmine": "^3.1.1",
"karma-spec-reporter": "0.0.32",
"mocha": "^7.1.1"
And my Karma.config.js file:还有我的 Karma.config.js 文件:
module.exports = function(config) {
config.set({
basePath: "",
frameworks: ["jasmine"],
Preprocessors: {
//'./Control/**/*.js': ['babel'],
// './lib/**/*.js': ['babel'],
//'./Module/**/*.js': ['babel'],
'../lib/Element/BaseElement.js': ['babel'],
'../test/BaseElement.test.js ': ['babel']
},
babelPreprocessor: {
options: {
presets: ['@babel/preset-env']
}
},
plugins: [
'@babel/core',
'karma-jasmine',
'karma-chrome-launcher',
'karma-babel-preprocessor'
],
files: [
{pattern: '../lib/Element/BaseElement.js', watched: true, included: true, served: true},
{ pattern: "*.test.js", type: "module", included: true }
],
//reporters: ['jasmine'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["Chrome"],
singleRun: true,
concurrency: Infinity
});
};
When I output using the --log-level debug flag, nothing about preprocessing appear.当我使用 --log-level 调试标志 output 时,没有出现任何关于预处理的信息。
The files are located like this:这些文件的位置如下:
in root: package.json
在根目录中:
package.json
in root/test: BaseElement.test.js
and karma.conf.js
在根/测试中:
BaseElement.test.js
和karma.conf.js
in root/lib/Element BaseElement.js
在
root/lib/Element BaseElement.js
Any help would be appreciated.任何帮助,将不胜感激。 Thanks.
谢谢。
I found the problem.我发现了问题。 It is preprocessor instead of Preprocessor.
它是预处理器而不是预处理器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.