Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 315b72d

Browse filesBrowse files
author
Andy
authored
Use it instead of describe for tests (microsoft#16172)
* Use `it` instead of `describe` for tests * Create SourceFiles lazily * Use before() hooks
1 parent b8d39d7 commit 315b72d
Copy full SHA for 315b72d

1 file changed

+9-6Lines changed: 9 additions & 6 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/harness/unittests/printer.ts‎

Copy file name to clipboardExpand all lines: src/harness/unittests/printer.ts
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.