Skip to content

Commit 99bc7ed

Browse files
author
VladimirAmiorkov
committed
chore: fix incorrect temlateUrl in component
chore: update karma config for latest CLI beta 6.0.0
1 parent ec586d1 commit 99bc7ed

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

tests/app/snippets/navigation/router-extensions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { RouterExtensions } from "nativescript-angular/router";
44
@Component({
55
// ...
66
// >> (hide)
7+
moduleId: module.id,
78
selector: "router-extensions-import",
8-
templateUrl: "snippets/navigation/router-extensions.html"
9+
templateUrl: "router-extensions.html"
910
// << (hide)
1011
})
1112
export class MyComponent {

tests/karma.conf.js

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = function(config) {
2-
config.set({
3-
browserNoActivityTimeout: 40000,
1+
module.exports = function (config) {
2+
const options = {
43

54
// base path that will be used to resolve all patterns (eg. files, exclude)
65
basePath: '',
@@ -12,6 +11,8 @@ module.exports = function(config) {
1211

1312

1413
// list of files / patterns to load in the browser
14+
// files: ['app/tests/**/*.ts'],
15+
1516
files: [
1617
'app/tests/test-main.js',
1718
'app/**/*.js',
@@ -32,7 +33,7 @@ module.exports = function(config) {
3233
// test results reporter to use
3334
// possible values: 'dots', 'progress'
3435
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
35-
reporters: ['mocha'],
36+
reporters: ['progress'],
3637

3738

3839
// web server port
@@ -49,7 +50,7 @@ module.exports = function(config) {
4950

5051

5152
// enable / disable watching file and executing tests whenever any file changes
52-
autoWatch: false,
53+
autoWatch: true,
5354

5455

5556
// start these browsers
@@ -74,6 +75,40 @@ module.exports = function(config) {
7475

7576
// Continuous Integration mode
7677
// if true, Karma captures browsers, runs the tests and exits
77-
singleRun: true
78-
})
78+
singleRun: false
79+
};
80+
81+
setWebpackPreprocessor(config, options);
82+
setWebpack(config, options);
83+
84+
config.set(options);
85+
}
86+
87+
function setWebpackPreprocessor(config, options) {
88+
if (config && config.bundle) {
89+
if (!options.preprocessors) {
90+
options.preprocessors = {};
91+
}
92+
93+
options.files.forEach(file => {
94+
if (!options.preprocessors[file]) {
95+
options.preprocessors[file] = [];
96+
}
97+
options.preprocessors[file].push('webpack');
98+
});
99+
}
100+
}
101+
102+
function setWebpack(config, options) {
103+
if (config && config.bundle) {
104+
const env = {};
105+
env[config.platform] = true;
106+
env.sourceMap = config.debugBrk;
107+
options.webpack = require('./webpack.config')(env);
108+
delete options.webpack.entry;
109+
delete options.webpack.output.libraryTarget;
110+
111+
const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"];
112+
options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name));
113+
}
79114
}

0 commit comments

Comments
 (0)