Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

test(js-sdk): add unit tests for string API key constructor

Himadri Mffdb6c1a206e
diff --git a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/clientOptions.test.ts b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/clientOptions.test.ts
index e7c3702ac..16441a736 100644
--- a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/clientOptions.test.ts
+++ b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/clientOptions.test.ts
@@ -1,4 +1,4 @@
-import { Firecrawl, type FirecrawlClientOptions } from '../../../index';
+import { Firecrawl, FirecrawlClient, type FirecrawlClientOptions } from '../../../index';
describe('Firecrawl v2 Client Options', () => {
it('should accept v2 options including timeoutMs, maxRetries, and backoffFactor', () => {
@@ -52,4 +52,28 @@ describe('Firecrawl v2 Client Options', () => {
expect(options.timeoutMs).toBe(300);
expect(options.apiKey).toBe('test-key');
});
+
+ it('should accept a string API key in Firecrawl constructor', () => {
+ const client = new Firecrawl('test-key');
+
+ expect(client).toBeDefined();
+ expect(client).toBeInstanceOf(Firecrawl);
+ });
+
+ it('should accept a string API key in FirecrawlClient constructor', () => {
+ const client = new FirecrawlClient('test-key');
+
+ expect(client).toBeDefined();
+ expect(client).toBeInstanceOf(FirecrawlClient);
+ });
+
+ it('should throw for empty string API key on cloud', () => {
+ expect(() => new Firecrawl('')).toThrow('API key is required');
+ });
+
+ it('should provide v1 accessor when constructed with string', () => {
+ const client = new Firecrawl('test-key');
+
+ expect(client.v1).toBeDefined();
+ });
});