Allow .ts or no extension for yarn test:single
These are all valid:
yarn test:single gr-alert_test.ts
yarn test:single gr-alert_test.js
yarn test:single gr-alert_test
Change-Id: Ie27ae126e6d4f940dab59dacf1cebadd5cb9d81e
diff --git a/polygerrit-ui/karma.conf.js b/polygerrit-ui/karma.conf.js
index fe3fa0c..00ebc63 100644
--- a/polygerrit-ui/karma.conf.js
+++ b/polygerrit-ui/karma.conf.js
@@ -67,11 +67,23 @@
// It can be just a file name, without a path:
// --test-files async-foreach-behavior_test.js
// If you specify --test-files without pattern, it gets true value
- // In this case we ill run all tests (usefull for package.json "debugtest"
+ // In this case we will run all tests (usefull for package.json "debugtest"
// script)
- const testFilesPattern = (typeof config.testFiles == 'string') ?
- testFilesLocationPattern + config.testFiles :
- testFilesLocationPattern + '*_test.js';
+ // We will convert a .ts argument to .js and fill in .js if no extension is
+ // given.
+ let filePattern;
+ if (typeof config.testFiles === "string") {
+ if (config.testFiles.endsWith('.ts')) {
+ filePattern = config.testFiles.substr(0, config.testFiles.lastIndexOf(".")) + ".js";
+ } else if (config.testFiles.endsWith('.js')) {
+ filePattern = config.testFiles;
+ } else {
+ filePattern = config.testFiles + '.js';
+ }
+ } else {
+ filePattern = '*_test.js';
+ }
+ const testFilesPattern = testFilesLocationPattern + filePattern;
// Special patch for grep parameters (see details in the grep-patch-karam.js)
const additionalFiles = runUnderBazel ? [] : ['polygerrit-ui/grep-patch-karma.js'];
config.set({