forked from NationalBankBelgium/stark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(stark-all): simplify karma configuration in stark-* packages + s…
…howcase ISSUES CLOSED: #1145
- Loading branch information
1 parent
7b2352b
commit 16e15bb
Showing
10 changed files
with
141 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const helpers = require("./stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
*/ | ||
const defaultKarmaCIConfig = require("./stark-testing/karma.conf.ci.js").rawKarmaConfig; | ||
const { karmaTypescriptBundlerAlias, karmaTypescriptFiles } = require("./karma.conf"); | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkPackagesSpecificConfiguration = { | ||
...defaultKarmaCIConfig, | ||
// change the path of the report so that Coveralls takes the right path to the source files | ||
coverageIstanbulReporter: { ...defaultKarmaCIConfig.coverageIstanbulReporter, dir: helpers.root("reports/coverage/packages") }, | ||
// add missing files due to "@nationalbankbelgium/stark-ui" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles], | ||
karmaTypescriptConfig: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, | ||
// change the module resolution for the KarmaTypescript bundler | ||
resolve: { | ||
alias: karmaTypescriptBundlerAlias | ||
}, | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
transforms: [ | ||
require(helpers.root("../stark-testing/node_modules/karma-typescript-angular2-transform")), | ||
require(helpers.root("../stark-testing/node_modules/karma-typescript-es6-transform"))({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = { | ||
default: function(config) { | ||
return config.set(starkPackagesSpecificConfiguration); | ||
}, | ||
rawKarmaConfig: starkPackagesSpecificConfiguration | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const helpers = require("./stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
*/ | ||
const defaultKarmaConfig = require("./stark-testing/karma.conf.js").rawKarmaConfig; | ||
|
||
// entry files of the "@nationalbankbelgium/stark-ui" module imported in mock files | ||
const karmaTypescriptFiles = [{ pattern: helpers.root("public_api.ts") }, { pattern: helpers.root("testing/**/*.ts") }]; | ||
|
||
const karmaTypescriptBundlerAlias = { | ||
// adapt the resolution of the stark-core module to the UMD module | ||
"@nationalbankbelgium/stark-core": "../../dist/packages/stark-core/bundles/stark-core.umd.js", | ||
"@nationalbankbelgium/stark-core/testing": "../../dist/packages/stark-core/bundles/stark-core-testing.umd.js", | ||
// adapt the resolution of the 3rd party modules used in stark-core | ||
"@angularclass/hmr": "../stark-core/node_modules/@angularclass/hmr/dist/index.js", | ||
"@ng-idle/core": "../stark-core/node_modules/@ng-idle/core/bundles/core.umd.js", | ||
"@ng-idle/keepalive": "../stark-core/node_modules/@ng-idle/keepalive/bundles/keepalive.umd.js", | ||
"@ngrx/store": "../stark-core/node_modules/@ngrx/store/bundles/store.umd.js", | ||
"@ngrx/effects": "../stark-core/node_modules/@ngrx/effects/bundles/effects.umd.js", | ||
"@ngrx/effects/testing": "../stark-core/node_modules/@ngrx/effects/bundles/effects-testing.umd.js", | ||
"@ngx-translate/core": "../stark-core/node_modules/@ngx-translate/core/bundles/ngx-translate-core.umd.js", | ||
"@uirouter/angular": "../stark-core/node_modules/@uirouter/angular/_bundles/ui-router-ng2.js", | ||
"@uirouter/core": "../stark-core/node_modules/@uirouter/core/lib/index.js", | ||
"@uirouter/rx": "../stark-core/node_modules/@uirouter/rx/lib/index.js", | ||
cerialize: "../stark-core/node_modules/cerialize/index.js", | ||
"class-validator": "../stark-core/node_modules/class-validator/index.js", | ||
"deep-freeze-strict": "../stark-core/node_modules/deep-freeze-strict/index.js", | ||
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js", | ||
"lodash-es": "../stark-core/node_modules/lodash-es/lodash.js", | ||
"lodash-es/cloneDeep": "../stark-core/node_modules/lodash-es/cloneDeep.js", | ||
"lodash-es/find": "../stark-core/node_modules/lodash-es/find.js", | ||
"lodash-es/findIndex": "../stark-core/node_modules/lodash-es/findIndex.js", | ||
"lodash-es/floor": "../stark-core/node_modules/lodash-es/floor.js", | ||
"lodash-es/get": "../stark-core/node_modules/lodash-es/get.js", | ||
"lodash-es/isEmpty": "../stark-core/node_modules/lodash-es/isEmpty.js", | ||
"lodash-es/isEqual": "../stark-core/node_modules/lodash-es/isEqual.js", | ||
"lodash-es/merge": "../stark-core/node_modules/lodash-es/merge.js", | ||
"lodash-es/noop": "../stark-core/node_modules/lodash-es/noop.js", | ||
"lodash-es/sortBy": "../stark-core/node_modules/lodash-es/sortBy.js", | ||
"lodash-es/reduce": "../stark-core/node_modules/lodash-es/reduce.js", | ||
"lodash-es/startCase": "../stark-core/node_modules/lodash-es/startCase.js", | ||
"lodash-es/uniqueId": "../stark-core/node_modules/lodash-es/uniqueId.js", | ||
moment: "../stark-core/node_modules/moment/moment.js" | ||
}; | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkPackagesSpecificConfiguration = { | ||
...defaultKarmaConfig, | ||
// add missing files due to "@nationalbankbelgium/stark-*" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaConfig.files, ...karmaTypescriptFiles], | ||
karmaTypescriptConfig: { | ||
...defaultKarmaConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaConfig.karmaTypescriptConfig.bundlerOptions, | ||
// change the module resolution for the KarmaTypescript bundler | ||
resolve: { | ||
alias: karmaTypescriptBundlerAlias | ||
}, | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
transforms: [ | ||
require(helpers.root("../stark-testing/node_modules/karma-typescript-angular2-transform")), | ||
require(helpers.root("../stark-testing/node_modules/karma-typescript-es6-transform"))({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = { | ||
default: function(config) { | ||
return config.set(starkPackagesSpecificConfiguration); | ||
}, | ||
karmaTypescriptBundlerAlias, | ||
karmaTypescriptFiles, | ||
rawKarmaConfig: starkPackagesSpecificConfiguration | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,11 @@ | ||
const helpers = require("../stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
* Load packages karma config | ||
*/ | ||
const defaultKarmaCIConfig = require("../stark-testing/karma.conf.ci.js").rawKarmaConfig; | ||
const karmaTypescriptFiles = require("./karma.conf").karmaTypescriptFiles; | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkCoreSpecificConfiguration = Object.assign({}, defaultKarmaCIConfig, { | ||
// change the path of the report so that Coveralls takes the right path to the source files | ||
coverageIstanbulReporter: Object.assign(defaultKarmaCIConfig.coverageIstanbulReporter, { | ||
dir: helpers.root("reports/coverage/packages") | ||
}), | ||
// add missing files due to "@nationalbankbelgium/stark-core" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles], | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
karmaTypescriptConfig: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, | ||
transforms: [ | ||
require("../stark-testing/node_modules/karma-typescript-angular2-transform"), | ||
require("../stark-testing/node_modules/karma-typescript-es6-transform")({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}); | ||
const rawKarmaConfig = require("../karma.conf.ci.js").rawKarmaConfig; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = config => { | ||
return config.set(starkCoreSpecificConfiguration); | ||
return config.set(rawKarmaConfig); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,11 @@ | ||
const helpers = require("../stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
* Load packages karma config | ||
*/ | ||
const defaultKarmaConfig = require("../stark-testing/karma.conf.js").rawKarmaConfig; | ||
|
||
// entry files of the "@nationalbankbelgium/stark-core" module imported in mock files | ||
const karmaTypescriptFiles = [{ pattern: helpers.root("public_api.ts") }, { pattern: helpers.root("testing/**/*.ts") }]; | ||
|
||
// start customizing the Karma configuration from stark-testing | ||
const starkCoreSpecificConfiguration = Object.assign({}, defaultKarmaConfig, { | ||
// add missing files due to "@nationalbankbelgium/stark-core" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaConfig.files, ...karmaTypescriptFiles], | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
karmaTypescriptConfig: { | ||
...defaultKarmaConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaConfig.karmaTypescriptConfig.bundlerOptions, | ||
transforms: [ | ||
require("../stark-testing/node_modules/karma-typescript-angular2-transform"), | ||
require("../stark-testing/node_modules/karma-typescript-es6-transform")({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}); | ||
const rawKarmaConfig = require("../karma.conf.js").rawKarmaConfig; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = { | ||
default: function(config) { | ||
return config.set(starkCoreSpecificConfiguration); | ||
}, | ||
karmaTypescriptFiles: karmaTypescriptFiles | ||
module.exports = config => { | ||
return config.set(rawKarmaConfig); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
const helpers = require("../stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
* Load packages karma config | ||
*/ | ||
const defaultKarmaCIConfig = require("../stark-testing/karma.conf.ci.js").rawKarmaConfig; | ||
const karmaTypescriptBundlerAliasResolution = require("./karma.conf").karmaTypescriptBundlerAliasResolution; | ||
const karmaTypescriptFiles = require("./karma.conf").karmaTypescriptFiles; | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkRBACSpecificConfiguration = { | ||
...defaultKarmaCIConfig, | ||
// change the path of the report so that Coveralls takes the right path to the source files | ||
coverageIstanbulReporter: { ...defaultKarmaCIConfig.coverageIstanbulReporter, dir: helpers.root("reports/coverage/packages") }, | ||
// add missing files due to "@nationalbankbelgium/stark-rbac" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles], | ||
karmaTypescriptConfig: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, | ||
// change the module resolution for the KarmaTypescript bundler | ||
...karmaTypescriptBundlerAliasResolution, | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
transforms: [ | ||
require("../stark-testing/node_modules/karma-typescript-angular2-transform"), | ||
require("../stark-testing/node_modules/karma-typescript-es6-transform")({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}; | ||
const rawKarmaConfig = require("../karma.conf.ci.js").rawKarmaConfig; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = config => { | ||
return config.set(starkRBACSpecificConfiguration); | ||
return config.set(rawKarmaConfig); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,11 @@ | ||
const helpers = require("../stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
* Load packages karma config | ||
*/ | ||
const defaultKarmaConfig = require("../stark-testing/karma.conf.js").rawKarmaConfig; | ||
|
||
// entry files of the "@nationalbankbelgium/stark-rbac" module imported in mock files | ||
const karmaTypescriptFiles = [{ pattern: helpers.root("public_api.ts") }, { pattern: helpers.root("testing/**/*.ts") }]; | ||
|
||
const karmaTypescriptBundlerAliasResolution = { | ||
resolve: { | ||
alias: { | ||
// adapt the resolution of the stark-core module to the UMD module | ||
"@nationalbankbelgium/stark-core": "../../dist/packages/stark-core/bundles/stark-core.umd.js", | ||
"@nationalbankbelgium/stark-core/testing": "../../dist/packages/stark-core/bundles/stark-core-testing.umd.js", | ||
// adapt the resolution of the 3rd party modules used in stark-core | ||
"@angularclass/hmr": "../stark-core/node_modules/@angularclass/hmr/dist/index.js", | ||
"@ng-idle/core": "../stark-core/node_modules/@ng-idle/core/bundles/core.umd.js", | ||
"@ng-idle/keepalive": "../stark-core/node_modules/@ng-idle/keepalive/bundles/keepalive.umd.js", | ||
"@ngrx/store": "../stark-core/node_modules/@ngrx/store/bundles/store.umd.js", | ||
"@ngrx/effects": "../stark-core/node_modules/@ngrx/effects/bundles/effects.umd.js", | ||
"@ngx-translate/core": "../stark-core/node_modules/@ngx-translate/core/bundles/ngx-translate-core.umd.js", | ||
"@uirouter/angular": "../stark-core/node_modules/@uirouter/angular/_bundles/ui-router-ng2.js", | ||
"@uirouter/core": "../stark-core/node_modules/@uirouter/core/lib/index.js", | ||
"@uirouter/rx": "../stark-core/node_modules/@uirouter/rx/lib/index.js", | ||
cerialize: "../stark-core/node_modules/cerialize/index.js", | ||
"class-validator": "../stark-core/node_modules/class-validator/index.js", | ||
"deep-freeze-strict": "../stark-core/node_modules/deep-freeze-strict/index.js", | ||
ibantools: "../stark-core/node_modules/ibantools/build/ibantools.js", | ||
"lodash-es": "../stark-core/node_modules/lodash-es/lodash.js", | ||
"lodash-es/cloneDeep": "../stark-core/node_modules/lodash-es/cloneDeep.js", | ||
"lodash-es/floor": "../stark-core/node_modules/lodash-es/floor.js", | ||
"lodash-es/isEmpty": "../stark-core/node_modules/lodash-es/isEmpty.js", | ||
"lodash-es/noop": "../stark-core/node_modules/lodash-es/noop.js", | ||
"lodash-es/reduce": "../stark-core/node_modules/lodash-es/reduce.js", | ||
moment: "../stark-core/node_modules/moment/moment.js" | ||
} | ||
} | ||
}; | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkRBACSpecificConfiguration = { | ||
...defaultKarmaConfig, | ||
// add missing files due to "@nationalbankbelgium/stark-rbac" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaConfig.files, ...karmaTypescriptFiles], | ||
karmaTypescriptConfig: { | ||
...defaultKarmaConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaConfig.karmaTypescriptConfig.bundlerOptions, | ||
// change the module resolution for the KarmaTypescript bundler | ||
...karmaTypescriptBundlerAliasResolution, | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
transforms: [ | ||
require("../stark-testing/node_modules/karma-typescript-angular2-transform"), | ||
require("../stark-testing/node_modules/karma-typescript-es6-transform")({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}; | ||
const rawKarmaConfig = require("../karma.conf.js").rawKarmaConfig; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = { | ||
default: function(config) { | ||
return config.set(starkRBACSpecificConfiguration); | ||
}, | ||
karmaTypescriptBundlerAliasResolution: karmaTypescriptBundlerAliasResolution, | ||
karmaTypescriptFiles: karmaTypescriptFiles | ||
module.exports = config => { | ||
return config.set(rawKarmaConfig); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,11 @@ | ||
const helpers = require("../stark-testing/helpers"); | ||
|
||
/** | ||
* Load karma config from Stark | ||
* Load packages karma config | ||
*/ | ||
const defaultKarmaCIConfig = require("../stark-testing/karma.conf.ci.js").rawKarmaConfig; | ||
const karmaTypescriptBundlerAlias = require("./karma.conf").karmaTypescriptBundlerAlias; | ||
const karmaTypescriptFiles = require("./karma.conf").karmaTypescriptFiles; | ||
|
||
// start customizing the KarmaCI configuration from stark-testing | ||
const starkUiSpecificConfiguration = { | ||
...defaultKarmaCIConfig, | ||
// change the path of the report so that Coveralls takes the right path to the source files | ||
coverageIstanbulReporter: { ...defaultKarmaCIConfig.coverageIstanbulReporter, dir: helpers.root("reports/coverage/packages") }, | ||
// add missing files due to "@nationalbankbelgium/stark-ui" imports used in mock files of the testing sub-package | ||
files: [...defaultKarmaCIConfig.files, ...karmaTypescriptFiles], | ||
karmaTypescriptConfig: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig, | ||
bundlerOptions: { | ||
...defaultKarmaCIConfig.karmaTypescriptConfig.bundlerOptions, | ||
// change the module resolution for the KarmaTypescript bundler | ||
resolve: { | ||
alias: karmaTypescriptBundlerAlias | ||
}, | ||
// Overwrite the karmaTypescriptConfig to pass the correct preset to karma-typescript-es6-transform | ||
transforms: [ | ||
require("../stark-testing/node_modules/karma-typescript-angular2-transform"), | ||
require("../stark-testing/node_modules/karma-typescript-es6-transform")({ | ||
presets: [helpers.root("../stark-testing/node_modules/babel-preset-env")] // add preset in a way that the package can find it | ||
}) | ||
] | ||
} | ||
} | ||
}; | ||
const rawKarmaConfig = require("../karma.conf.ci.js").rawKarmaConfig; | ||
|
||
// export the configuration function that karma expects and simply return the stark configuration | ||
module.exports = config => { | ||
return config.set(starkUiSpecificConfiguration); | ||
return config.set(rawKarmaConfig); | ||
}; |
Oops, something went wrong.