|
1 | 1 | namespace ts {
|
2 |
| - describe("unittests:: tsbuild:: with resolveJsonModule option", () => { |
| 2 | + describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => { |
3 | 3 | let projFs: vfs.FileSystem;
|
4 | 4 | const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/hello.json"];
|
5 | 5 | before(() => {
|
@@ -63,19 +63,92 @@ export default hello.hello`);
|
63 | 63 | const configFile = "src/tsconfig_withFiles.json";
|
64 | 64 | replaceText(fs, configFile, `"composite": true,`, `"composite": true, "sourceMap": true,`);
|
65 | 65 | const host = new fakes.SolutionBuilderHost(fs);
|
66 |
| - const builder = createSolutionBuilder(host, [configFile], { verbose: false }); |
| 66 | + const builder = createSolutionBuilder(host, [configFile], { verbose: true }); |
67 | 67 | builder.buildAllProjects();
|
68 |
| - host.assertDiagnosticMessages(); |
| 68 | + host.assertDiagnosticMessages( |
| 69 | + getExpectedDiagnosticForProjectsInBuild(configFile), |
| 70 | + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, configFile, "src/dist/src/index.js"], |
| 71 | + [Diagnostics.Building_project_0, `/${configFile}`] |
| 72 | + ); |
69 | 73 | for (const output of [...allExpectedOutputs, "/src/dist/src/index.js.map"]) {
|
70 | 74 | assert(fs.existsSync(output), `Expect file ${output} to exist`);
|
71 | 75 | }
|
72 |
| - |
73 |
| - const newBuilder = createSolutionBuilder(host, [configFile], { verbose: true }); |
74 |
| - newBuilder.buildAllProjects(); |
| 76 | + host.clearDiagnostics(); |
| 77 | + builder.resetBuildContext(); |
| 78 | + builder.buildAllProjects(); |
75 | 79 | host.assertDiagnosticMessages(
|
76 | 80 | getExpectedDiagnosticForProjectsInBuild(configFile),
|
77 | 81 | [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, configFile, "src/src/index.ts", "src/dist/src/index.js"]
|
78 | 82 | );
|
79 | 83 | });
|
| 84 | + |
| 85 | + it("with resolveJsonModule and without outDir", () => { |
| 86 | + const fs = projFs.shadow(); |
| 87 | + const configFile = "src/tsconfig_withFiles.json"; |
| 88 | + replaceText(fs, configFile, `"outDir": "dist",`, ""); |
| 89 | + const host = new fakes.SolutionBuilderHost(fs); |
| 90 | + const builder = createSolutionBuilder(host, [configFile], { verbose: true }); |
| 91 | + builder.buildAllProjects(); |
| 92 | + host.assertDiagnosticMessages( |
| 93 | + getExpectedDiagnosticForProjectsInBuild(configFile), |
| 94 | + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, configFile, "src/src/index.js"], |
| 95 | + [Diagnostics.Building_project_0, `/${configFile}`] |
| 96 | + ); |
| 97 | + for (const output of ["/src/src/index.js", "/src/src/index.d.ts"]) { |
| 98 | + assert(fs.existsSync(output), `Expect file ${output} to exist`); |
| 99 | + } |
| 100 | + host.clearDiagnostics(); |
| 101 | + builder.resetBuildContext(); |
| 102 | + builder.buildAllProjects(); |
| 103 | + host.assertDiagnosticMessages( |
| 104 | + getExpectedDiagnosticForProjectsInBuild(configFile), |
| 105 | + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, configFile, "src/src/index.ts", "src/src/index.js"] |
| 106 | + ); |
| 107 | + }); |
| 108 | + }); |
| 109 | + |
| 110 | + describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { |
| 111 | + let projFs: vfs.FileSystem; |
| 112 | + before(() => { |
| 113 | + projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference"); |
| 114 | + }); |
| 115 | + |
| 116 | + after(() => { |
| 117 | + projFs = undefined!; // Release the contents |
| 118 | + }); |
| 119 | + |
| 120 | + it("when importing json module from project reference", () => { |
| 121 | + const expectedOutput = "/src/main/index.js"; |
| 122 | + const fs = projFs.shadow(); |
| 123 | + const configFile = "src/tsconfig.json"; |
| 124 | + const stringsConfigFile = "src/strings/tsconfig.json"; |
| 125 | + const mainConfigFile = "src/main/tsconfig.json"; |
| 126 | + const host = new fakes.SolutionBuilderHost(fs); |
| 127 | + const builder = createSolutionBuilder(host, [configFile], { verbose: true }); |
| 128 | + builder.buildAllProjects(); |
| 129 | + host.assertDiagnosticMessages( |
| 130 | + getExpectedDiagnosticForProjectsInBuild(stringsConfigFile, mainConfigFile, configFile), |
| 131 | + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, stringsConfigFile, "src/strings/tsconfig.tsbuildinfo"], |
| 132 | + [Diagnostics.Building_project_0, `/${stringsConfigFile}`], |
| 133 | + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, mainConfigFile, "src/main/index.js"], |
| 134 | + [Diagnostics.Building_project_0, `/${mainConfigFile}`], |
| 135 | + [Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, "/src/strings/foo.json"], |
| 136 | + [Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, configFile, mainConfigFile], |
| 137 | + [Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, `/${configFile}`, `/${mainConfigFile}`] |
| 138 | + ); |
| 139 | + assert.isFalse(fs.existsSync(expectedOutput), `Expect file ${expectedOutput} to not exist because of errors`); |
| 140 | + host.clearDiagnostics(); |
| 141 | + builder.resetBuildContext(); |
| 142 | + builder.buildAllProjects(); |
| 143 | + host.assertDiagnosticMessages( |
| 144 | + getExpectedDiagnosticForProjectsInBuild(stringsConfigFile, mainConfigFile, configFile), |
| 145 | + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, stringsConfigFile, "src/strings/foo.json", "src/strings/tsconfig.tsbuildinfo"], |
| 146 | + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, mainConfigFile, "src/main/index.js"], |
| 147 | + [Diagnostics.Building_project_0, `/${mainConfigFile}`], |
| 148 | + [Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, "/src/strings/foo.json"], |
| 149 | + [Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, configFile, mainConfigFile], |
| 150 | + [Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, `/${configFile}`, `/${mainConfigFile}`] |
| 151 | + ); |
| 152 | + }); |
80 | 153 | });
|
81 | 154 | }
|
0 commit comments