Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit a223b2b

Browse files
committed
fix: respect files property from karma.config on tns test android --bundle command
Rel to: NativeScript/nativescript-cli#4477 NativeScript/nativescript-cli#1798
1 parent d6f6672 commit a223b2b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

unit-testing-config-loader.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { join, relative } = require("path");
22

33
module.exports = function ({ appFullPath, projectRoot, angular, rootPagesRegExp }) {
4-
// TODO: Consider to use the files property from karma.conf.js
5-
const testFilesRegExp = /tests\/.*\.js/;
4+
const testFilesRegExp = getKarmaConfig().files;
65
const runnerFullPath = join(projectRoot, "node_modules", "nativescript-unit-test-runner");
76
const runnerRelativePath = relative(appFullPath, runnerFullPath);
87
let source = `
@@ -30,4 +29,16 @@ module.exports = function ({ appFullPath, projectRoot, angular, rootPagesRegExp
3029
`;
3130

3231
return source;
32+
}
33+
34+
function getKarmaConfig() {
35+
let result = { files: /tests\/.*\.(js|ts)/ };
36+
const pathToKarmaConfig = join(__dirname, "../../karma.conf.js");
37+
if (existsSync(pathToKarmaConfig)) {
38+
try {
39+
require(pathToKarmaConfig)({ set: (options) => result = options });
40+
} catch (err) { }
41+
}
42+
43+
return result;
3344
}

0 commit comments

Comments
 (0)