mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
tests
This commit is contained in:
parent
45091430ab
commit
be5e6da5ff
|
@ -10,142 +10,142 @@ dotenv.config();
|
||||||
const TEST_URL = "http://127.0.0.1:3002";
|
const TEST_URL = "http://127.0.0.1:3002";
|
||||||
|
|
||||||
describe("E2E Tests for Extract API Routes", () => {
|
describe("E2E Tests for Extract API Routes", () => {
|
||||||
describe("POST /v1/extract", () => {
|
it.concurrent("should return authors of blog posts on firecrawl.dev", async () => {
|
||||||
it.concurrent("should return authors of blog posts on firecrawl.dev", async () => {
|
const response = await request(TEST_URL)
|
||||||
const response = await request(TEST_URL)
|
.post("/v1/extract")
|
||||||
.post("/v1/extract")
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
.set("Content-Type", "application/json")
|
||||||
.set("Content-Type", "application/json")
|
.send({
|
||||||
.send({
|
urls: ["https://firecrawl.dev"],
|
||||||
urls: ["https://firecrawl.dev"],
|
prompt: "Who are the authors of the blog posts?",
|
||||||
prompt: "Who are the authors of the blog posts?",
|
schema: {
|
||||||
schema: {
|
type: "object",
|
||||||
type: "object",
|
properties: { authors: { type: "array", items: { type: "string" } } },
|
||||||
properties: { authors: { type: "array", items: { type: "string" } } },
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body).toHaveProperty("data");
|
|
||||||
expect(response.body.data).toHaveProperty("founders");
|
|
||||||
|
|
||||||
let gotItRight = 0;
|
console.log(response.body);
|
||||||
for (const author of response.body.data?.authors) {
|
expect(response.statusCode).toBe(200);
|
||||||
if (author.includes("Caleb Peffer")) gotItRight++;
|
expect(response.body).toHaveProperty("data");
|
||||||
if (author.includes("Gergő Móricz")) gotItRight++;
|
expect(response.body.data).toHaveProperty("authors");
|
||||||
if (author.includes("Eric Ciarla")) gotItRight++;
|
|
||||||
if (author.includes("Nicolas Camara")) gotItRight++;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(gotItRight).toBeGreaterThan(3);
|
let gotItRight = 0;
|
||||||
}, 60000);
|
for (const author of response.body.data?.authors) {
|
||||||
|
if (author.includes("Caleb Peffer")) gotItRight++;
|
||||||
|
if (author.includes("Gergő Móricz")) gotItRight++;
|
||||||
|
if (author.includes("Eric Ciarla")) gotItRight++;
|
||||||
|
if (author.includes("Nicolas Camara")) gotItRight++;
|
||||||
|
}
|
||||||
|
|
||||||
it.concurrent("should return founders of firecrawl.dev (allowExternalLinks = true)", async () => {
|
expect(gotItRight).toBeGreaterThan(1);
|
||||||
const response = await request(TEST_URL)
|
}, 60000);
|
||||||
.post("/v1/extract")
|
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
|
||||||
.set("Content-Type", "application/json")
|
|
||||||
.send({
|
|
||||||
urls: ["mendable.ai"],
|
|
||||||
prompt: "Who are the founders of the company?",
|
|
||||||
allowExternalLinks: true,
|
|
||||||
schema: {
|
|
||||||
type: "object",
|
|
||||||
properties: { founders: { type: "array", items: { type: "string" } } },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body).toHaveProperty("data");
|
|
||||||
expect(response.body.data).toHaveProperty("founders");
|
|
||||||
|
|
||||||
let gotItRight = 0;
|
it.concurrent("should return founders of firecrawl.dev (allowExternalLinks = true)", async () => {
|
||||||
for (const founder of response.body.data?.founders) {
|
const response = await request(TEST_URL)
|
||||||
if (founder.includes("Caleb")) gotItRight++;
|
.post("/v1/extract")
|
||||||
if (founder.includes("Eric")) gotItRight++;
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
if (founder.includes("Nicolas")) gotItRight++;
|
.set("Content-Type", "application/json")
|
||||||
}
|
.send({
|
||||||
|
urls: ["mendable.ai"],
|
||||||
|
prompt: "Who are the founders of the company?",
|
||||||
|
allowExternalLinks: true,
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: { founders: { type: "array", items: { type: "string" } } },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(response.body).toHaveProperty("data");
|
||||||
|
expect(response.body.data).toHaveProperty("founders");
|
||||||
|
|
||||||
expect(gotItRight).toBe(3);
|
let gotItRight = 0;
|
||||||
}, 60000);
|
for (const founder of response.body.data?.founders) {
|
||||||
|
if (founder.includes("Caleb")) gotItRight++;
|
||||||
|
if (founder.includes("Eric")) gotItRight++;
|
||||||
|
if (founder.includes("Nicolas")) gotItRight++;
|
||||||
|
}
|
||||||
|
|
||||||
it.concurrent("should return hiring opportunities on firecrawl.dev (allowExternalLinks = true)", async () => {
|
expect(gotItRight).toBe(3);
|
||||||
const response = await request(TEST_URL)
|
}, 60000);
|
||||||
.post("/v1/extract")
|
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
|
||||||
.set("Content-Type", "application/json")
|
|
||||||
.send({
|
|
||||||
urls: ["https://firecrawl.dev"],
|
|
||||||
prompt: "What are they hiring for?",
|
|
||||||
allowExternalLinks: true,
|
|
||||||
schema: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
type: "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body).toHaveProperty("data");
|
|
||||||
console.log(response.body.data);
|
|
||||||
|
|
||||||
let gotItRight = 0;
|
it.concurrent("should return hiring opportunities on firecrawl.dev (allowExternalLinks = true)", async () => {
|
||||||
for (const hiring of response.body.data?.items) {
|
const response = await request(TEST_URL)
|
||||||
if (hiring.includes("Developer Relations Specialist")) gotItRight++;
|
.post("/v1/extract")
|
||||||
if (hiring.includes("Web Automation Engineer")) gotItRight++;
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
if (hiring.includes("Developer Experience Engineer")) gotItRight++;
|
.set("Content-Type", "application/json")
|
||||||
if (hiring.includes("Developer Support Engineer")) gotItRight++;
|
.send({
|
||||||
if (hiring.includes("Dev Ops Engineer")) gotItRight++;
|
urls: ["https://firecrawl.dev"],
|
||||||
if (hiring.includes("Founding Web Automation Engineer")) gotItRight++;
|
prompt: "What are they hiring for?",
|
||||||
}
|
allowExternalLinks: true,
|
||||||
|
schema: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(response.body).toHaveProperty("data");
|
||||||
|
console.log(response.body.data);
|
||||||
|
|
||||||
expect(gotItRight).toBeGreaterThan(5);
|
let gotItRight = 0;
|
||||||
}, 60000);
|
for (const hiring of response.body.data?.items) {
|
||||||
|
if (hiring.includes("Developer Relations Specialist")) gotItRight++;
|
||||||
|
if (hiring.includes("Web Automation Engineer")) gotItRight++;
|
||||||
|
if (hiring.includes("Developer Experience Engineer")) gotItRight++;
|
||||||
|
if (hiring.includes("Developer Support Engineer")) gotItRight++;
|
||||||
|
if (hiring.includes("Dev Ops Engineer")) gotItRight++;
|
||||||
|
if (hiring.includes("Founding Web Automation Engineer")) gotItRight++;
|
||||||
|
}
|
||||||
|
|
||||||
it.concurrent("should return PCI DSS compliance for Fivetran", async () => {
|
expect(gotItRight).toBeGreaterThan(5);
|
||||||
const response = await request(TEST_URL)
|
}, 60000);
|
||||||
.post("/v1/extract")
|
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
it.concurrent("should return PCI DSS compliance for Fivetran", async () => {
|
||||||
.set("Content-Type", "application/json")
|
const response = await request(TEST_URL)
|
||||||
.send({
|
.post("/v1/extract")
|
||||||
urls: ["fivetran.com"],
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
prompt: "Does Fivetran have PCI DSS compliance?",
|
.set("Content-Type", "application/json")
|
||||||
allowExternalLinks: true,
|
.send({
|
||||||
schema: {
|
urls: ["fivetran.com"],
|
||||||
|
prompt: "Does Fivetran have PCI DSS compliance?",
|
||||||
|
allowExternalLinks: true,
|
||||||
|
schema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
pciDssCompliance: { type: "boolean" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
expect(response.body).toHaveProperty("data");
|
||||||
|
expect(response.body.data?.pciDssCompliance).toBe(true);
|
||||||
|
}, 60000);
|
||||||
|
|
||||||
|
it.concurrent("should return Azure Data Connectors for Fivetran", async () => {
|
||||||
|
const response = await request(TEST_URL)
|
||||||
|
.post("/v1/extract")
|
||||||
|
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
||||||
|
.set("Content-Type", "application/json")
|
||||||
|
.send({
|
||||||
|
urls: ["fivetran.com"],
|
||||||
|
prompt: "What are the Azure Data Connectors they offer?",
|
||||||
|
schema: {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
pciDssCompliance: { type: "boolean" }
|
connector: { type: "string" },
|
||||||
}
|
description: { type: "string" },
|
||||||
},
|
supportsCaptureDelete: { type: "boolean" }
|
||||||
});
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body).toHaveProperty("data");
|
|
||||||
expect(response.body.data?.pciDssCompliance).toBe(true);
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
it.concurrent("should return Azure Data Connectors for Fivetran", async () => {
|
|
||||||
const response = await request(TEST_URL)
|
|
||||||
.post("/v1/extract")
|
|
||||||
.set("Authorization", `Bearer ${process.env.TEST_API_KEY}`)
|
|
||||||
.set("Content-Type", "application/json")
|
|
||||||
.send({
|
|
||||||
urls: ["fivetran.com"],
|
|
||||||
prompt: "What are the Azure Data Connectors they offer?",
|
|
||||||
schema: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
connector: { type: "string" },
|
|
||||||
description: { type: "string" },
|
|
||||||
supportsCaptureDelete: { type: "boolean" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
console.log(response.body);
|
console.log(response.body);
|
||||||
// expect(response.statusCode).toBe(200);
|
// expect(response.statusCode).toBe(200);
|
||||||
// expect(response.body).toHaveProperty("data");
|
// expect(response.body).toHaveProperty("data");
|
||||||
// expect(response.body.data?.pciDssCompliance).toBe(true);
|
// expect(response.body.data?.pciDssCompliance).toBe(true);
|
||||||
}, 60000);
|
}, 60000);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -106,6 +106,15 @@ export interface FirecrawlCrawlStatusResponse {
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FirecrawlExtractResponse {
|
||||||
|
statusCode: number;
|
||||||
|
body: {
|
||||||
|
success: boolean;
|
||||||
|
data: any[];
|
||||||
|
};
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export enum RateLimiterMode {
|
export enum RateLimiterMode {
|
||||||
Crawl = "crawl",
|
Crawl = "crawl",
|
||||||
CrawlStatus = "crawlStatus",
|
CrawlStatus = "crawlStatus",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user