Skip to content

Commit fe489db

Browse files
speed up test
1 parent ef070c0 commit fe489db

File tree

1 file changed

+67
-57
lines changed

1 file changed

+67
-57
lines changed

e2e/resolve_ts_dependencies.spec.ts

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ if (
1919
templateFramework == "nextjs" ||
2020
templateFramework == "express" // test is only relevant for TS projects
2121
) {
22-
const llamaParseOptions = [true, false];
2322
// vectorDBs combinations to test
2423
const vectorDbs: TemplateVectorDB[] = [
2524
"mongo",
@@ -34,68 +33,79 @@ if (
3433
];
3534

3635
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}`;
4039

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+
});
4349

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();
6155

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;
6673

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+
}
8092

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();
91103

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;
99109
}
100110
}
101111
});

0 commit comments

Comments
 (0)