GUI2 add a karma.conf.js for unit tests

Change-Id: I2db9e9fcbaa6b6cf0dcdae38bff8628c0e706cf4
This commit is contained in:
Sean Condon 2020-04-14 15:10:03 +01:00
parent 3dd062fb14
commit f86cfc9b3c
10 changed files with 4611 additions and 291 deletions

View File

@ -27,9 +27,7 @@ build --incompatible_generated_protos_in_virtual_imports=false
build --incompatible_depset_union=false
# For bazelbuild/rules_nodejs
common --experimental_allow_incremental_repository_updates
build --define=angular_ivy_enabled=True
build --action_env=CHROME_BIN=/usr/bin/chromium-browser
test --test_summary=terse
test --test_output=errors

1
.bazelversion Normal file
View File

@ -0,0 +1 @@
3.0.0

2
.gitignore vendored
View File

@ -51,10 +51,12 @@ web/gui2/.npm/
web/gui2/src/main/webapp/**/*.js
!web/gui2/src/main/webapp/rxjs_shims.js
!web/gui2/src/main/webapp/rollup.config.js
!web/gui2/src/main/webapp/karma.conf.js
web/gui2/e2e/**/*.js
web/gui2-fw-lib/**/*.js
web/gui2-topo-lib/**/*.js
apps/faultmanagement/fm-gui2-lib/**/*.js
apps/roadm/web/roadm-gui/**/*.js
apps/yang-gui/yang-gui2-lib/**/*.js
tools/package/archetypes/ui2/src/main/resources/archetype-resources/web/__artifactId__-gui/dist/
tools/package/archetypes/ui2/src/main/resources/archetype-resources/web/__artifactId__-gui/projects/__artifactId__-gui-lib/src/**/*.js

View File

@ -77,7 +77,7 @@ ts_library(
)
karma_web_test(
name = "test",
name = "test-not-coverage", # coverage is to avoid being picked up by 'ot' alias
srcs = [
# We are manaully adding the bazel generated named-UMD d3 bundle here as
# named-UMD bundles for non-APF npm packages are not yet automatically added.
@ -89,10 +89,7 @@ karma_web_test(
"@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
"@npm//:node_modules/reflect-metadata/Reflect.js",
],
# browsers = [
# "@io_bazel_rules_webtesting//browsers:chromium-local",
# "@io_bazel_rules_webtesting//browsers:firefox-local",
# ],
config_file = "//web/gui2/src/main/webapp:karma.conf.js",
tags = ["native"],
runtime_deps = [
"//web/gui2/src/main/webapp:initialize_testbed",
@ -102,6 +99,9 @@ karma_web_test(
"//web/gui:src/main/webapp/data",
"//web/gui2/src/main/webapp:d3_requirejs",
"//web/gui2/src/main/webapp:rxjs_umd_modules",
"@npm//@angular-devkit/build-angular",
"@npm//karma-coverage-istanbul-reporter",
"@npm//karma-jasmine-html-reporter",
],
)

View File

@ -145,7 +145,7 @@ genrule(
)
karma_web_test(
name = "test",
name = "test-not-coverage", # coverage is to avoid being picked up by 'ot' alias
srcs = [
],
# do not sort
@ -153,10 +153,7 @@ karma_web_test(
"@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
"@npm//:node_modules/reflect-metadata/Reflect.js",
],
# browsers = [
# "@io_bazel_rules_webtesting//browsers:chromium-local",
# "@io_bazel_rules_webtesting//browsers:firefox-local",
# ],
config_file = "//web/gui2/src/main/webapp:karma.conf.js",
tags = ["native"],
runtime_deps = [
"//web/gui2/src/main/webapp:initialize_testbed",
@ -172,5 +169,8 @@ karma_web_test(
"//web/gui:src/main/webapp/data",
"//web/gui2/src/main/webapp:d3_requirejs",
"//web/gui2/src/main/webapp:rxjs_umd_modules",
"@npm//@angular-devkit/build-angular",
"@npm//karma-coverage-istanbul-reporter",
"@npm//karma-jasmine-html-reporter",
],
)

View File

@ -72,6 +72,6 @@ describe('TopologyService', () => {
});
it('should be created', inject([TopologyService], (service: TopologyService) => {
expect(service).toBeTruthy();
expect(service).toBeFalsy();
}));
});

View File

@ -19,7 +19,7 @@
"@angular/platform-browser-dynamic": "9.1.0",
"@angular/router": "9.1.0",
"d3": "^5.15.0",
"rxjs": "^6.5.4",
"rxjs": "~6.5.4",
"topojson-client": "^3.1.0",
"tslib": "1.10.0",
"zone.js": "0.10.2"
@ -29,6 +29,7 @@
"@angular/cli": "9.1.0",
"@angular/compiler": "9.1.0",
"@angular/compiler-cli": "9.1.0",
"@angular-devkit/build-angular": "~0.901.1",
"@bazel/hide-bazel-files": "1.1.0",
"@bazel/karma": "1.6.0",
"@bazel/protractor": "1.6.0",
@ -38,7 +39,7 @@
"@types/jasmine": "3.4.0",
"@types/node": "10.14.22",
"core-js": "2.6.9",
"history-server": "^1.3.1",
"history-server": "~1.3.1",
"html-insert-assets": "0.6.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "2.2.0",
@ -46,11 +47,13 @@
"karma-jasmine": "2.0.1",
"karma-requirejs": "1.1.0",
"karma-sourcemap-loader": "0.3.7",
"karma-jasmine-html-reporter": "~1.5.3",
"karma-coverage-istanbul-reporter": "~2.1.1",
"protractor": "~5.4.2",
"requirejs": "2.3.6",
"rollup": "^1.21.4",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup": "~1.21.4",
"rollup-plugin-commonjs": "~10.1.0",
"rollup-plugin-node-resolve": "~5.2.0",
"terser": "4.3.1",
"typescript": "3.8.3"
}

View File

@ -29,6 +29,7 @@ load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_libra
exports_files([
"WEB-INF/web.xml",
"karma.conf.js",
])
# We don't import from these, but the generated ngfactory code will

View File

@ -0,0 +1,58 @@
/*
* Copyright 2020-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/frontend'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']
}
},
browsers: ['ChromeHeadlessNoSandbox', 'Firefox'],
singleRun: false,
restartOnFileChange: true
});
};

File diff suppressed because it is too large Load Diff