Skip to content

Commit

Permalink
test: import
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Feb 11, 2025
1 parent f9aa762 commit fbe22d5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions e2e/node/smoke.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { testRootDir } from "./utils.js";

await test("cjs/esm dual module check", async (t) => {
const esmImports = `import fs from 'node:fs/promises'
import { Document, MetadataMode, NodeWithScore, VectorStoreIndex } from 'llamaindex'
import { Document, MetadataMode, VectorStoreIndex } from 'llamaindex'
import { OpenAIEmbedding } from '@llamaindex/openai'
import { Settings } from '@llamaindex/core/global'`;
const cjsRequire = `const fs = require('fs').promises
const { Document, MetadataMode, NodeWithScore, VectorStoreIndex } = require('llamaindex')
const { Document, MetadataMode, VectorStoreIndex } = require('llamaindex')
const { OpenAIEmbedding } = require('@llamaindex/openai')
const { Settings } = require('@llamaindex/core/global')`;
const mainCode = `
Expand Down Expand Up @@ -66,4 +66,21 @@ main().catch(console.error)`;
cwd: process.cwd(),
});
});

const specialConditions = ["edge-light", "workerd", "react-server"];
for (const condition of specialConditions) {
await t.test(condition, async () => {
const esmCode = `${esmImports}\n${mainCode}`;
const filePath = resolve(
testRootDir,
".temp",
`${crypto.randomUUID()}.mjs`,
);
await writeFile(filePath, esmCode, "utf-8");

execSync(`${process.argv[0]} ${filePath} -C ${condition}`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
cwd: process.cwd(),
});
});
}
});

0 comments on commit fbe22d5

Please sign in to comment.