1namespace ts { 2 describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => { 3 let projFs: vfs.FileSystem; 4 before(() => { 5 projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite"); 6 }); 7 8 after(() => { 9 projFs = undefined!; // Release the contents 10 }); 11 12 verifyTsc({ 13 scenario: "resolveJsonModule", 14 subScenario: "include only", 15 fs: () => projFs, 16 commandLineArgs: ["--b", "/src/tsconfig_withInclude.json", "--v", "--explainFiles"], 17 }); 18 19 verifyTsc({ 20 scenario: "resolveJsonModule", 21 subScenario: "include of json along with other include", 22 fs: () => projFs, 23 commandLineArgs: ["--b", "/src/tsconfig_withIncludeOfJson.json", "--v", "--explainFiles"], 24 }); 25 26 verifyTsc({ 27 scenario: "resolveJsonModule", 28 subScenario: "include of json along with other include and file name matches ts file", 29 fs: () => projFs, 30 commandLineArgs: ["--b", "/src/tsconfig_withIncludeOfJson.json", "--v", "--explainFiles"], 31 modifyFs: fs => { 32 fs.rimrafSync("/src/src/hello.json"); 33 fs.writeFileSync("/src/src/index.json", JSON.stringify({ hello: "world" })); 34 fs.writeFileSync("/src/src/index.ts", `import hello from "./index.json" 35 36export default hello.hello`); 37 }, 38 }); 39 40 verifyTsc({ 41 scenario: "resolveJsonModule", 42 subScenario: "files containing json file", 43 fs: () => projFs, 44 commandLineArgs: ["--b", "/src/tsconfig_withFiles.json", "--v", "--explainFiles"], 45 }); 46 47 verifyTsc({ 48 scenario: "resolveJsonModule", 49 subScenario: "include and files", 50 fs: () => projFs, 51 commandLineArgs: ["--b", "/src/tsconfig_withIncludeAndFiles.json", "--v", "--explainFiles"], 52 }); 53 54 verifyTscWithEdits({ 55 scenario: "resolveJsonModule", 56 subScenario: "sourcemap", 57 fs: () => projFs, 58 commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose", "--explainFiles"], 59 modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"composite": true,`, `"composite": true, "sourceMap": true,`), 60 edits: noChangeOnlyRuns 61 }); 62 63 verifyTscWithEdits({ 64 scenario: "resolveJsonModule", 65 subScenario: "without outDir", 66 fs: () => projFs, 67 commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose"], 68 modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"outDir": "dist",`, ""), 69 edits: noChangeOnlyRuns 70 }); 71 }); 72 73 describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { 74 verifyTscWithEdits({ 75 scenario: "resolveJsonModule", 76 subScenario: "importing json module from project reference", 77 fs: () => loadProjectFromDisk("tests/projects/importJsonFromProjectReference"), 78 commandLineArgs: ["--b", "src/tsconfig.json", "--verbose", "--explainFiles"], 79 edits: noChangeOnlyRuns 80 }); 81 }); 82} 83