|
19 | 19 | templateFramework == "nextjs" || |
20 | 20 | templateFramework == "express" // test is only relevant for TS projects |
21 | 21 | ) { |
22 | | - const llamaParseOptions = [true, false]; |
23 | 22 | // vectorDBs combinations to test |
24 | 23 | const vectorDbs: TemplateVectorDB[] = [ |
25 | 24 | "mongo", |
|
34 | 33 | ]; |
35 | 34 |
|
36 | 35 | test.describe("Test resolve TS dependencies", () => { |
37 | | - for (const llamaParseOpt of llamaParseOptions) { |
38 | | - for (const vectorDb of vectorDbs) { |
39 | | - const optionDescription = `vectorDb: ${vectorDb}, dataSource: ${dataSource}, llamaParse: ${llamaParseOpt}`; |
| 36 | + // Test vector DBs without LlamaParse |
| 37 | + for (const vectorDb of vectorDbs) { |
| 38 | + const optionDescription = `vectorDb: ${vectorDb}, dataSource: ${dataSource}`; |
40 | 39 |
|
41 | | - test(`options: ${optionDescription}`, async () => { |
42 | | - const cwd = await createTestDir(); |
| 40 | + test(`Vector DB test - ${optionDescription}`, async () => { |
| 41 | + await runTest(vectorDb, false); |
| 42 | + }); |
| 43 | + } |
| 44 | + |
| 45 | + // Test LlamaParse with vectorDB 'none' |
| 46 | + test(`LlamaParse test - vectorDb: none, dataSource: ${dataSource}, llamaParse: true`, async () => { |
| 47 | + await runTest("none", true); |
| 48 | + }); |
43 | 49 |
|
44 | | - const result = await runCreateLlama({ |
45 | | - cwd: cwd, |
46 | | - templateType: "streaming", |
47 | | - templateFramework: templateFramework, |
48 | | - dataSource: dataSource, |
49 | | - vectorDb: vectorDb, |
50 | | - port: 3000, |
51 | | - externalPort: 8000, |
52 | | - postInstallAction: "none", |
53 | | - templateUI: undefined, |
54 | | - appType: templateFramework === "nextjs" ? "" : "--no-frontend", |
55 | | - llamaCloudProjectName: undefined, |
56 | | - llamaCloudIndexName: undefined, |
57 | | - tools: undefined, |
58 | | - useLlamaParse: llamaParseOpt, |
59 | | - }); |
60 | | - const name = result.projectName; |
| 50 | + async function runTest( |
| 51 | + vectorDb: TemplateVectorDB | "none", |
| 52 | + useLlamaParse: boolean, |
| 53 | + ) { |
| 54 | + const cwd = await createTestDir(); |
61 | 55 |
|
62 | | - // Check if the app folder exists |
63 | | - const appDir = path.join(cwd, name); |
64 | | - const dirExists = fs.existsSync(appDir); |
65 | | - expect(dirExists).toBeTruthy(); |
| 56 | + const result = await runCreateLlama({ |
| 57 | + cwd: cwd, |
| 58 | + templateType: "streaming", |
| 59 | + templateFramework: templateFramework, |
| 60 | + dataSource: dataSource, |
| 61 | + vectorDb: vectorDb, |
| 62 | + port: 3000, |
| 63 | + externalPort: 8000, |
| 64 | + postInstallAction: "none", |
| 65 | + templateUI: undefined, |
| 66 | + appType: templateFramework === "nextjs" ? "" : "--no-frontend", |
| 67 | + llamaCloudProjectName: undefined, |
| 68 | + llamaCloudIndexName: undefined, |
| 69 | + tools: undefined, |
| 70 | + useLlamaParse: useLlamaParse, |
| 71 | + }); |
| 72 | + const name = result.projectName; |
66 | 73 |
|
67 | | - // Install dependencies using pnpm |
68 | | - try { |
69 | | - const { stderr: installStderr } = await execAsync( |
70 | | - "pnpm install --prefer-offline", |
71 | | - { |
72 | | - cwd: appDir, |
73 | | - }, |
74 | | - ); |
75 | | - expect(installStderr).toBeFalsy(); |
76 | | - } catch (error) { |
77 | | - console.error("Error installing dependencies:", error); |
78 | | - throw error; |
79 | | - } |
| 74 | + // Check if the app folder exists |
| 75 | + const appDir = path.join(cwd, name); |
| 76 | + const dirExists = fs.existsSync(appDir); |
| 77 | + expect(dirExists).toBeTruthy(); |
| 78 | + |
| 79 | + // Install dependencies using pnpm |
| 80 | + try { |
| 81 | + const { stderr: installStderr } = await execAsync( |
| 82 | + "pnpm install --prefer-offline", |
| 83 | + { |
| 84 | + cwd: appDir, |
| 85 | + }, |
| 86 | + ); |
| 87 | + expect(installStderr).toBeFalsy(); |
| 88 | + } catch (error) { |
| 89 | + console.error("Error installing dependencies:", error); |
| 90 | + throw error; |
| 91 | + } |
80 | 92 |
|
81 | | - // Run tsc type check and capture the output |
82 | | - try { |
83 | | - const { stdout, stderr } = await execAsync( |
84 | | - "pnpm exec tsc -b --diagnostics", |
85 | | - { |
86 | | - cwd: appDir, |
87 | | - }, |
88 | | - ); |
89 | | - // Check if there's any error output |
90 | | - expect(stderr).toBeFalsy(); |
| 93 | + // Run tsc type check and capture the output |
| 94 | + try { |
| 95 | + const { stdout, stderr } = await execAsync( |
| 96 | + "pnpm exec tsc -b --diagnostics", |
| 97 | + { |
| 98 | + cwd: appDir, |
| 99 | + }, |
| 100 | + ); |
| 101 | + // Check if there's any error output |
| 102 | + expect(stderr).toBeFalsy(); |
91 | 103 |
|
92 | | - // Log the stdout for debugging purposes |
93 | | - console.log("TypeScript type-check output:", stdout); |
94 | | - } catch (error) { |
95 | | - console.error("Error running tsc:", error); |
96 | | - throw error; |
97 | | - } |
98 | | - }); |
| 104 | + // Log the stdout for debugging purposes |
| 105 | + console.log("TypeScript type-check output:", stdout); |
| 106 | + } catch (error) { |
| 107 | + console.error("Error running tsc:", error); |
| 108 | + throw error; |
99 | 109 | } |
100 | 110 | } |
101 | 111 | }); |
|
0 commit comments