add test coverage

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: Iac976a49157954185cf59c7c352488221e961795
This commit is contained in:
houhaoyu 2023-07-24 16:55:14 +08:00
parent 93b8e8c818
commit 84866eee74
4 changed files with 31 additions and 3 deletions

4
.gitignore vendored
View File

@ -5,4 +5,6 @@ compiler/declarations/
compiler/sample/build/
compiler/component_config.json
compiler/form_config.json
compiler/syntax_parser/dist/
compiler/syntax_parser/dist/
compiler/.nyc_output
compiler/.test_output

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
<!-- Copyright (c) 2021-2023 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@
<filefilterlist>
<filefilter name="defaultFilter" desc="Files not to check">
<filteritem type="filepath" name="compiler/node_modules/.*" desc="dependencies of ets-loader"/>
<filteritem type="filepath" name="compiler/.nycrc" desc="nyc config file"/>
<filteritem type="filepath" name="compiler/lib/.*" desc="files generated by ets-loader"/>
<filteritem type="filepath" name="compiler/syntax_parser/dist/.*" desc="files generated by ets-loader"/>
</filefilter>

23
compiler/.nycrc Normal file
View File

@ -0,0 +1,23 @@
{
"all": true,
"include": [
"lib/component_map.js",
"lib/ets_checker.js",
"lib/process_component_build.js",
"lib/process_component_class.js",
"lib/process_component_constructor.js",
"lib/process_component_member.js",
"lib/process_custom_component.js",
"lib/process_import.js",
"lib/process_system_module.js",
"lib/process_ui_syntax.js",
"lib/utils.js",
"lib/validate_ui_syntax.js"
],
"reporter":[
"text-summary",
"html",
"lcovonly"
],
"report-dir": ".test_output/coverage"
}

View File

@ -14,12 +14,14 @@
"create": "node ./lib/create.js --env projectName",
"compile": "webpack --config webpack.config.js --env buildMode=debug projectName",
"test": "npm run build && mocha test/test.js && mocha test/test.js --partialUpdate && npm run arkTest",
"test:coverage": "npm run generateDeclarations && ./node_modules/.bin/babel ./src --out-dir lib --extensions .ts && mocha test/test.js && mocha test/test.js --partialUpdate",
"generateDeclarations": "node ./build_declarations_file.js ../../../interface/sdk-js/api/@internal/component/ets ./declarations ./lib",
"postinstall": "node npm-install.js",
"fastbuild": "rollup -c rollup.config.js",
"run:arkTest": "mocha \"arkTest_build/ark_compiler_ut/**/*.test.js\"",
"run:cleanArkTest": "rm -rf arkTest_build",
"arkTest": "./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest"
"arkTest": "./node_modules/.bin/babel ./test/ark_compiler_ut --out-dir arkTest_build/ark_compiler_ut --extensions .ts && npm run run:arkTest && npm run run:cleanArkTest",
"coverage": "node_modules/nyc/bin/nyc.js npm run test:coverage"
},
"devDependencies": {
"@babel/cli": "7.20.7",