Update index.test.ts
This commit is contained in:
parent
b7e3104c7b
commit
a0a67f124a
@ -57,7 +57,7 @@ describe("Scraping/Crawling Checkup (E2E)", () => {
|
|||||||
.post("/v0/scrape")
|
.post("/v0/scrape")
|
||||||
.set("Content-Type", "application/json")
|
.set("Content-Type", "application/json")
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
.send({ url: websiteData.website });
|
.send({ url: websiteData.website, pageOptions: { onlyMainContent: true } });
|
||||||
|
|
||||||
if (scrapedContent.statusCode !== 200) {
|
if (scrapedContent.statusCode !== 200) {
|
||||||
console.error(`Failed to scrape ${websiteData.website}`);
|
console.error(`Failed to scrape ${websiteData.website}`);
|
||||||
@ -138,15 +138,14 @@ describe("Scraping/Crawling Checkup (E2E)", () => {
|
|||||||
batchPromises.push(batchPromise);
|
batchPromises.push(batchPromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
const responses = (await Promise.all(batchPromises)).flat();
|
(await Promise.all(batchPromises)).flat();
|
||||||
const validResponses = responses.filter((response) => response !== null);
|
const score = (passedTests / websitesData.length) * 100;
|
||||||
const score = (passedTests / validResponses.length) * 100;
|
|
||||||
const endTime = new Date().getTime();
|
const endTime = new Date().getTime();
|
||||||
const timeTaken = (endTime - startTime) / 1000;
|
const timeTaken = (endTime - startTime) / 1000;
|
||||||
console.log(`Score: ${score}%`);
|
console.log(`Score: ${score}%`);
|
||||||
console.log(`Total tokens: ${totalTokens}`);
|
console.log(`Total tokens: ${totalTokens}`);
|
||||||
|
|
||||||
await logErrors(errorLog, timeTaken, totalTokens, score, validResponses.length);
|
await logErrors(errorLog, timeTaken, totalTokens, score, websitesData.length);
|
||||||
|
|
||||||
if (process.env.ENV === "local" && errorLog.length > 0) {
|
if (process.env.ENV === "local" && errorLog.length > 0) {
|
||||||
if (!fs.existsSync(logsDir)){
|
if (!fs.existsSync(logsDir)){
|
||||||
|
Loading…
Reference in New Issue
Block a user