我正在尝试使用Sonar Qube和Jest框架来建立覆盖范围。我发现jest-sonar-reporter(https://www.npmjs.com/package/jest-sonar-reporter)由于使用flowtype.js无法解析某些文件。
这是travis构建日志的一部分:
ERROR: Failed to parse file [file:///home/travis/build/my-project/front-end/src/actions/paymentActions.js] at line 4: Unexpected token : (with espree parser in module mode)
ERROR: Failed to parse file [file:///home/travis/build/my-project/front-end/src/components/AddressField/index.js] at line 10: Unexpected token Props (with espree parser in module mode)
ERROR: Failed to parse file [file:///home/travis/build/my-project/front-end/src/components/AppealsSlider/AppealsSlider.js] at line 23: The keyword 'interface' is reserved (with espree parser in module mode)
我在日志中看到很多相同的记录。有人可以帮我找出我做错了什么吗?这是我的sonar-project.properties
文件:
# Must be unique in a given SonarQube instance
sonar.projectKey=myproject_front-end
# Name and version displayed in the SonarQube UI.
sonar.projectName=My Project Front End
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Optional if sonar.modules is set.
sonar.sources=src
sonar.tests=src
sonar.exclusions=node_modules/**
sonar.test.inclusions=src/**/*.spec.js
sonar.javascript.lcov.reportPaths=coverage/jest/lcov.info
sonar.testExecutionReportPaths=coverage/jest/testlog.xml
# Encoding of the source code. By default, the system encoding
#sonar.sourceEncoding=UTF-8
这是我的package.json
文件的笑话部分:
"jest": {
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tools/assetsTransformer.js",
"\\.(css|scss)$": "<rootDir>/tools/assetsTransformer.js"
},
"setupFiles": [
"raf/polyfill",
"./tools/enzymeTestAdapterSetup.js"
],
"testResultsProcessor": "jest-sonar-reporter"
},
谢谢。