From 866552882ab16303461b3fb215b3f11f84c35b44 Mon Sep 17 00:00:00 2001 From: Michael HENKENS Date: Mon, 27 Nov 2023 10:11:08 +0100 Subject: [PATCH] chore(all): aply remarks --- karma-stark.conf.js | 100 ------------------ karma.conf.ci.js | 12 --- karma.conf.js | 98 +++++++++++++++-- helpers.js => scripts/helpers.js | 0 .../form-errors-group.directive.spec.ts | 1 - src/directives/form-errors.directive.spec.ts | 5 +- .../form-errors-message.service.spec.ts | 1 - tsconfig.lib.json | 4 +- 8 files changed, 92 insertions(+), 129 deletions(-) delete mode 100644 karma-stark.conf.js delete mode 100644 karma.conf.ci.js rename helpers.js => scripts/helpers.js (100%) diff --git a/karma-stark.conf.js b/karma-stark.conf.js deleted file mode 100644 index 25aba7e..0000000 --- a/karma-stark.conf.js +++ /dev/null @@ -1,100 +0,0 @@ -// Helpers -const helpers = require("./helpers"); -const ciInfo = require("ci-info"); -const isCI = process.argv.indexOf("--watch=false") > -1 || ciInfo.isCI; - -const rawKarmaConfig = { - // base path that will be used to resolve all patterns (e.g. files, exclude) - basePath: "", - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ["jasmine", "@angular-devkit/build-angular"], - - // list of files to exclude - exclude: [ - helpers.root("src/index.html") // not needed for unit testing - ], - - client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - - plugins: [ - // Default karma plugins configuration: require("karma-*") - "karma-*", - require("@angular-devkit/build-angular/plugins/karma") - ], - - // test results reporter to use - // possible values: "dots", "progress", "spec", "junit", "mocha", "coverage" (others if you import reporters) - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - // https://www.npmjs.com/package/karma-junit-reporter - // https://www.npmjs.com/package/karma-spec-reporter - reporters: isCI ? ["mocha", "progress"] : ["mocha", "progress", "kjhtml", "coverage"], - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // see: http://karma-runner.github.io/2.0/config/configuration-file.html - // possible values: - // "OFF" = config.LOG_DISABLE - // "ERROR" = config.LOG_ERROR - // "WARN" = config.LOG_WARN - // "INFO" = config.LOG_INFO - // "DEBUG" = config.LOG_DEBUG - // raw value defined in node_modules/karma/lib/constants.js - logLevel: "WARN", - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: isCI ? ["ChromeHeadlessNoSandbox"] : ["Chrome"], - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: isCI, - - // If true, tests restart automatically if a file is changed - restartOnFileChange: !isCI, - - // Timeout settings - browserNoActivityTimeout: 30000, - browserDisconnectTolerance: 1, - browserDisconnectTimeout: 30000, - - // Configuration for coverage-istanbul reporter - coverageReporter: { - // base output directory. If you include %browser% in the path it will be replaced with the karma browser name - dir: helpers.root("reports/coverage"), - subdir: ".", - // https://github.com/istanbuljs/istanbuljs/tree/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib - reporters: [{ type: "html" }, { type: "lcovonly" }, { type: "text-summary" }, { type: "clover" }, { type: "json" }] - }, - - // Custom launcher configuration for ChromeHeadless (with Puppeteer) - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: "ChromeHeadless", - // necessary for travis: https://github.com/puppeteer/puppeteer/blob/v7.1.0/docs/troubleshooting.md#setting-up-chrome-linux-sandbox - // as it runs in a container-based environment - flags: ["--no-sandbox", "--disable-setuid-sandbox"] - } - } -}; - -module.exports = { - // Karma configuration - // reference: http://karma-runner.github.io/2.0/config/configuration-file.html - default: function (config) { - config.set(rawKarmaConfig); - }, - rawKarmaConfig: rawKarmaConfig, - isCITest: isCI -}; diff --git a/karma.conf.ci.js b/karma.conf.ci.js deleted file mode 100644 index 811e008..0000000 --- a/karma.conf.ci.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Load karma config from Stark - */ -const defaultKarmaCIConfig = require("./karma-stark.conf.js").rawKarmaConfig; - -// start customizing the KarmaCI configuration from stark-testing -const ngxFormErrorsSpecificConfiguration = Object.assign({}, defaultKarmaCIConfig); - -// export the configuration function that karma expects and simply return the stark configuration -module.exports = config => { - return config.set(ngxFormErrorsSpecificConfiguration); -}; diff --git a/karma.conf.js b/karma.conf.js index 089a88c..377907c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,16 +1,96 @@ -const helpers = require("./helpers"); +// Helpers +const helpers = require("./scripts/helpers"); +const ciInfo = require("ci-info"); +const isCI = process.argv.indexOf("--watch=false") > -1 || ciInfo.isCI; -/** - * Load karma config from Stark - */ -const defaultKarmaConfig = require("./karma-stark.conf.js").rawKarmaConfig; +const ngxFormErrorsSpecificConfiguration = { + // base path that will be used to resolve all patterns (e.g. files, exclude) + basePath: "", -// start customizing the KarmaCI configuration from stark-testing -const ngxFormErrorsSpecificConfiguration = Object.assign({}, defaultKarmaConfig); + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ["jasmine", "@angular-devkit/build-angular"], + + // list of files to exclude + exclude: [ + helpers.root("src/index.html") // not needed for unit testing + ], + + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + + plugins: [ + // Default karma plugins configuration: require("karma-*") + "karma-*", + require("@angular-devkit/build-angular/plugins/karma") + ], + + // test results reporter to use + // possible values: "dots", "progress", "spec", "junit", "mocha", "coverage" (others if you import reporters) + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + // https://www.npmjs.com/package/karma-junit-reporter + // https://www.npmjs.com/package/karma-spec-reporter + reporters: isCI ? ["mocha", "progress"] : ["mocha", "progress", "kjhtml", "coverage"], + + // web server port + port: 9876, + + // enable / disable colors in the output (reporters and logs) + colors: true, + + // level of logging + // see: http://karma-runner.github.io/2.0/config/configuration-file.html + // possible values: + // "OFF" = config.LOG_DISABLE + // "ERROR" = config.LOG_ERROR + // "WARN" = config.LOG_WARN + // "INFO" = config.LOG_INFO + // "DEBUG" = config.LOG_DEBUG + // raw value defined in node_modules/karma/lib/constants.js + logLevel: "WARN", + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: isCI ? ["ChromeHeadlessNoSandbox"] : ["Chrome"], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: isCI, + + // If true, tests restart automatically if a file is changed + restartOnFileChange: !isCI, + + // Timeout settings + browserNoActivityTimeout: 30000, + browserDisconnectTolerance: 1, + browserDisconnectTimeout: 30000, + + // Configuration for coverage-istanbul reporter + coverageReporter: { + // base output directory. If you include %browser% in the path it will be replaced with the karma browser name + dir: helpers.root("reports/coverage"), + subdir: ".", + // https://github.com/istanbuljs/istanbuljs/tree/73c25ce79f91010d1ff073aa6ff3fd01114f90db/packages/istanbul-reports/lib + reporters: [{ type: "html" }, { type: "lcovonly" }, { type: "text-summary" }, { type: "clover" }, { type: "json" }] + }, + + // Custom launcher configuration for ChromeHeadless (with Puppeteer) + customLaunchers: { + ChromeHeadlessNoSandbox: { + base: "ChromeHeadless", + // necessary for travis: https://github.com/puppeteer/puppeteer/blob/v7.1.0/docs/troubleshooting.md#setting-up-chrome-linux-sandbox + // as it runs in a container-based environment + flags: ["--no-sandbox", "--disable-setuid-sandbox"] + } + } +}; -// export the configuration function that karma expects and simply return the stark configuration module.exports = { - default: function(config) { + default: function (config) { return config.set(ngxFormErrorsSpecificConfiguration); } }; diff --git a/helpers.js b/scripts/helpers.js similarity index 100% rename from helpers.js rename to scripts/helpers.js diff --git a/src/directives/form-errors-group.directive.spec.ts b/src/directives/form-errors-group.directive.spec.ts index a97453f..3248f1c 100644 --- a/src/directives/form-errors-group.directive.spec.ts +++ b/src/directives/form-errors-group.directive.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable */ import { Component, ViewChild } from "@angular/core"; import { ComponentFixture, fakeAsync, TestBed } from "@angular/core/testing"; import { NgxFormErrorsGroupDirective } from "./form-errors-group.directive"; diff --git a/src/directives/form-errors.directive.spec.ts b/src/directives/form-errors.directive.spec.ts index 996b550..e33f4dc 100644 --- a/src/directives/form-errors.directive.spec.ts +++ b/src/directives/form-errors.directive.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable */ import { Component, ViewChild } from "@angular/core"; import { FormBuilder, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from "@angular/forms"; import { ComponentFixture, fakeAsync, TestBed } from "@angular/core/testing"; @@ -113,9 +112,7 @@ describe("NgxFormErrorsDirective", () => { @Component({ selector: "form-error", - template: ` -
some content here
- ` + template: `
some content here
` }) class FormErrorComponent implements NgxFormErrorComponent { public errors$!: Observable; diff --git a/src/services/form-errors-message.service.spec.ts b/src/services/form-errors-message.service.spec.ts index de03863..b50bfe2 100644 --- a/src/services/form-errors-message.service.spec.ts +++ b/src/services/form-errors-message.service.spec.ts @@ -1,4 +1,3 @@ -/* eslint-disable */ import { NgxFormErrorsMessageService, NgxValidationErrorFieldNames, NgxValidationErrorMessages } from "./form-errors-message.service"; describe("NgxFormErrorsMessageService", () => { diff --git a/tsconfig.lib.json b/tsconfig.lib.json index be75428..8103951 100644 --- a/tsconfig.lib.json +++ b/tsconfig.lib.json @@ -12,6 +12,6 @@ "declarationDir": "AUTOGENERATED", "inlineSourceMap": true }, - "exclude": ["node_modules", "dist", "demo-app", "**/*.spec.ts"] - /* "files": ["AUTOGENERATED"] */ + "exclude": ["node_modules", "dist", "demo-app", "**/*.spec.ts"], + "files": ["AUTOGENERATED"] }