11export class KarmaFilesService {
2- private extensionRegex = / \. ( [ ^ . \/ ] + ) $ / ;
3- private appPrefix = null ;
4- private testsPrefix = null ;
5- private nodeModulesPrefix = null ;
6- private bundle = false ;
2+ private readonly extensionRegex = / \. ( [ ^ . \/ ] + ) $ / ;
3+ private readonly appPrefix = null ;
4+ private readonly testsPrefix = null ;
5+ private readonly absoluteTestsPrefix = null ;
6+ private readonly nodeModulesPrefix = null ;
7+ private readonly bundle : boolean = false ;
78
89 constructor ( private http , config : IHostConfiguration ) {
910 this . appPrefix = `/base/${ config . options . appDirectoryRelativePath } /` ;
1011 this . testsPrefix = `/base/${ config . options . appDirectoryRelativePath } /tests` ;
12+ this . absoluteTestsPrefix = `/absolute` ;
1113 this . nodeModulesPrefix = `/base/node_modules/` ;
1214 this . bundle = config . options . bundle ;
1315 }
1416
1517 public getServedFilesData ( baseUrl : string ) : Promise < IScriptInfo [ ] > {
1618 const contextUrl = `${ baseUrl } /context.json` ;
1719 console . log ( "NSUTR: downloading " + contextUrl ) ;
18-
19- const result = this . http . getString ( contextUrl )
20+
21+ return this . http . getString ( contextUrl )
2022 . then ( content => {
21- var parsedContent : IKarmaContext = JSON . parse ( content ) ;
23+ const parsedContent : IKarmaContext = JSON . parse ( content ) ;
2224 return parsedContent . files ;
2325 } )
2426 . then ( scriptUrls => {
@@ -37,14 +39,12 @@ export class KarmaFilesService {
3739 url,
3840 type,
3941 contents,
40- shouldEval : ! extension || extension . toLowerCase ( ) === "js"
42+ shouldEval : ! extension || extension . toLowerCase ( ) === "js" || extension . toLowerCase ( ) === "ts"
4143 } ;
4244 } ) ;
4345 }
4446 } ) ) ;
4547 } ) ;
46-
47- return result ;
4848 }
4949
5050 private getScriptData ( url : string ) : { extension : string , localPath : string , type : ScriptTypes } {
@@ -65,7 +65,7 @@ export class KarmaFilesService {
6565 private getScriptType ( url : string ) : ScriptTypes {
6666 let type = ScriptTypes . CodeUnderTestType ;
6767
68- if ( url . startsWith ( this . testsPrefix ) ) {
68+ if ( url . startsWith ( this . testsPrefix ) || url . startsWith ( this . absoluteTestsPrefix ) ) {
6969 type = ScriptTypes . TestType ;
7070 } else if ( url . startsWith ( this . nodeModulesPrefix ) ) {
7171 type = ScriptTypes . FrameworkAdapterType ;
@@ -86,4 +86,4 @@ export class KarmaFilesService {
8686
8787 return localPath ;
8888 }
89- }
89+ }
0 commit comments