@@ -14,7 +14,9 @@ namespace ts {
1414
1515 describe ( "printFile" , ( ) => {
1616 const printsCorrectly = makePrintsCorrectly ( "printsFileCorrectly" ) ;
17- const sourceFile = createSourceFile ( "source.ts" , `
17+ // Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run.
18+ let sourceFile : SourceFile ;
19+ before ( ( ) => sourceFile = createSourceFile ( "source.ts" , `
1820 interface A<T> {
1921 // comment1
2022 readonly prop?: T;
@@ -48,8 +50,7 @@ namespace ts {
4850
4951 // comment10
5052 function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
51- ` , ScriptTarget . ES2015 ) ;
52-
53+ ` , ScriptTarget . ES2015 ) ) ;
5354 printsCorrectly ( "default" , { } , printer => printer . printFile ( sourceFile ) ) ;
5455 printsCorrectly ( "removeComments" , { removeComments : true } , printer => printer . printFile ( sourceFile ) ) ;
5556
@@ -59,7 +60,8 @@ namespace ts {
5960
6061 describe ( "printBundle" , ( ) => {
6162 const printsCorrectly = makePrintsCorrectly ( "printsBundleCorrectly" ) ;
62- const bundle = createBundle ( [
63+ let bundle : Bundle ;
64+ before ( ( ) => bundle = createBundle ( [
6365 createSourceFile ( "a.ts" , `
6466 /*! [a.ts] */
6567
@@ -72,14 +74,15 @@ namespace ts {
7274 // comment1
7375 const b = 2;
7476 ` , ScriptTarget . ES2015 )
75- ] ) ;
77+ ] ) ) ;
7678 printsCorrectly ( "default" , { } , printer => printer . printBundle ( bundle ) ) ;
7779 printsCorrectly ( "removeComments" , { removeComments : true } , printer => printer . printBundle ( bundle ) ) ;
7880 } ) ;
7981
8082 describe ( "printNode" , ( ) => {
8183 const printsCorrectly = makePrintsCorrectly ( "printsNodeCorrectly" ) ;
82- const sourceFile = createSourceFile ( "source.ts" , "" , ScriptTarget . ES2015 ) ;
84+ let sourceFile : SourceFile ;
85+ before ( ( ) => sourceFile = createSourceFile ( "source.ts" , "" , ScriptTarget . ES2015 ) ) ;
8386 // tslint:disable boolean-trivia
8487 const syntheticNode = createClassDeclaration (
8588 undefined ,
0 commit comments