Skip to content

Commit 2109bb3

Browse files
committed
✅ use default node test methods
1 parent 7221920 commit 2109bb3

6 files changed

Lines changed: 39 additions & 47 deletions

File tree

tests/v1/extraction/invoiceSplitter.integration.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import assert from "node:assert/strict";
2+
import { beforeEach, describe, it } from "node:test";
23
import { promises as fs } from "fs";
34
import path from "path";
45
import * as mindee from "@/index.js";
56
import { InvoiceSplitterV1 } from "@/v1/product/index.js";
67
import { levenshteinRatio } from "../../testingUtilities.js";
78
import { V1_PRODUCT_PATH } from "../../index.js";
89

9-
describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", async () => {
10+
describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", { timeout: 60000 }, () => {
1011
let client: mindee.v1.Client;
1112

1213
beforeEach(() => {
@@ -44,7 +45,7 @@ describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRequired", asy
4445
testStringRstInvoice.toString()
4546
) >= 0.90
4647
);
47-
}).timeout(60000);
48+
});
4849
});
4950

5051
describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRemoved", function () {
@@ -79,5 +80,5 @@ describe("MindeeV1 - Integration - InvoiceSplitterV1 #OptionalDepsRemoved", func
7980
throw error;
8081
}
8182
}
82-
}).timeout(60000);
83+
});
8384
});

tests/v1/extraction/multiReceipts.integration.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { before, describe, it } from "node:test";
12
import assert from "node:assert/strict";
23
import * as path from "path";
34
import { Client } from "@/v1/index.js";
@@ -10,17 +11,8 @@ import { setTimeout } from "node:timers/promises";
1011
const apiKey = process.env.MINDEE_API_KEY;
1112
let client: Client;
1213
let sourceDoc: LocalInputSource;
13-
describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequired", () => {
14-
describe("A Multi-Receipt Image", () => {
15-
before(async () => {
16-
sourceDoc = new PathInput({
17-
inputPath: path.join(V1_PRODUCT_PATH, "multi_receipts_detector/default_sample.jpg"),
18-
});
19-
await sourceDoc.init();
20-
client = new Client({ apiKey });
21-
});
22-
});
23-
14+
describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequired", { timeout: 60000 }, () =>
15+
{
2416
describe("A Multi-Receipt PDF", () => {
2517
before(async () => {
2618
sourceDoc = new PathInput({
@@ -74,10 +66,9 @@ describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequire
7466
assert.strictEqual(fifthPrediction.lineItems.length, 1);
7567
assert.strictEqual(fifthPrediction.lineItems[0].totalAmount, 16.5);
7668

77-
}).timeout(60000);
69+
});
7870
});
7971

80-
8172
describe("A Single-Receipt Image", () => {
8273
before(async () => {
8374
sourceDoc = new PathInput({
@@ -97,6 +88,6 @@ describe("MindeeV1 - Integration - Multi-Receipt Extraction #OptionalDepsRequire
9788
assert.strictEqual(receiptResult.document.inference.prediction.lineItems[0].totalAmount, 10.2);
9889
assert.strictEqual(receiptResult.document.inference.prediction.taxes.length, 1);
9990
assert.strictEqual(receiptResult.document.inference.prediction.taxes[0].value, 1.7);
100-
}).timeout(60000);
91+
});
10192
});
10293
});

tests/v1/extras/extras.integration.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { beforeEach, describe, it } from "node:test";
12
import assert from "node:assert/strict";
23
import * as mindee from "@/index.js";
34
import path from "path";
45
import { V1_PRODUCT_PATH } from "../../index.js";
56

67

7-
describe("MindeeV1 - Integration - Extras", async () => {
8+
describe("MindeeV1 - Integration - Extras", { timeout: 70000 }, () => {
89
let client: mindee.v1.Client;
910

1011
beforeEach(() => {
@@ -20,7 +21,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
2021
mindee.v1.product.InvoiceV4, sample, { cropper: true }
2122
);
2223
assert.ok(response.document.inference.pages[0]?.extras?.cropper);
23-
}).timeout(70000);
24+
});
2425

2526
it("should send full text OCR extra", async () => {
2627
const sample = new mindee.PathInput({
@@ -31,8 +32,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
3132
mindee.v1.product.InternationalIdV2, sample, { fullText: true }
3233
);
3334
assert.ok(response.document?.extras?.fullTextOcr);
34-
35-
}).timeout(70000);
35+
});
3636

3737
it("should send OCR words synchronously", async () => {
3838
const sample = new mindee.PathInput({
@@ -44,8 +44,7 @@ describe("MindeeV1 - Integration - Extras", async () => {
4444
);
4545
assert.ok(response.document?.ocr);
4646
assert.ok(response.document?.ocr?.toString());
47-
48-
}).timeout(70000);
47+
});
4948

5049
it("should send OCR words asynchronously", async () => {
5150
const sample = new mindee.PathInput({
@@ -57,6 +56,5 @@ describe("MindeeV1 - Integration - Extras", async () => {
5756
);
5857
assert.ok(response.document?.ocr);
5958
assert.ok(response.document?.ocr?.toString());
60-
61-
}).timeout(70000);
59+
});
6260
});
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import * as mindee from "@/index.js";
2-
import { InvoiceV4 } from "@/v1/product/index.js";
1+
import { beforeEach, describe, it } from "node:test";
32
import assert from "node:assert";
3+
import path from "path";
44
import { promises as fs } from "fs";
55
import { createReadStream } from "node:fs";
6-
import path from "path";
6+
import * as mindee from "@/index.js";
7+
import { InvoiceV4 } from "@/v1/product/index.js";
78
import { V1_PRODUCT_PATH } from "../../index.js";
89
import { PathInput, Base64Input, BufferInput, BytesInput, UrlInput } from "@/index.js";
910

10-
describe("MindeeV1 - Integration - File Input", async () => {
11+
describe("MindeeV1 - Integration - File Input", { timeout: 60000 }, () => {
1112
let client: mindee.v1.Client;
1213
let filePath: string;
1314

@@ -21,15 +22,15 @@ describe("MindeeV1 - Integration - File Input", async () => {
2122
await pathInput.init();
2223
const result = await client.parse(InvoiceV4, pathInput);
2324
assert.strictEqual(typeof result.document.id, "string");
24-
}).timeout(60000);
25+
});
2526

2627
it("should send a base64 document", async () => {
2728
const content = await fs.readFile(filePath);
2829
const base64Content = content.toString("base64");
2930
const base64Input = new Base64Input({ inputString: base64Content, filename: "testFile.jpg" });
3031
const result = await client.parse(InvoiceV4, base64Input);
3132
assert.strictEqual(typeof result.document.id, "string");
32-
}).timeout(60000);
33+
});
3334

3435
it("should send a document from a readable stream", async () => {
3536
const fileStream = createReadStream(filePath);
@@ -41,23 +42,23 @@ describe("MindeeV1 - Integration - File Input", async () => {
4142
const streamInput = new BufferInput({ buffer: buffer, filename: "testFile.jpg" });
4243
const result = await client.parse(InvoiceV4, streamInput);
4344
assert.strictEqual(typeof result.document.id, "string");
44-
}).timeout(60000);
45+
});
4546

4647

4748
it("should send a document from bytes", async () => {
4849
const inputBytes = await fs.readFile(filePath);
4950
const bytesInput = new BytesInput({ inputBytes: inputBytes, filename: "testFile.jpg" });
5051
const result = await client.parse(InvoiceV4, bytesInput);
5152
assert.strictEqual(typeof result.document.id, "string");
52-
}).timeout(60000);
53+
});
5354

5455
it("should send a document from buffer", async () => {
5556
const buffer = await fs.readFile(filePath);
5657
const bufferInput = new BufferInput({ buffer: buffer, filename: "testFile.jpg" });
5758
await bufferInput.init();
5859
const result = await client.parse(InvoiceV4, bufferInput);
5960
assert.strictEqual(typeof result.document.id, "string");
60-
}).timeout(60000);
61+
});
6162

6263
it("should send a document from a URL", async () => {
6364
const url = "https://raw.githubusercontent.com/mindee/client-lib-test-data/" +
@@ -66,5 +67,5 @@ describe("MindeeV1 - Integration - File Input", async () => {
6667
await urlInput.init();
6768
const result = await client.parse(InvoiceV4, urlInput);
6869
assert.strictEqual(typeof result.document.id, "string");
69-
}).timeout(60000);
70-
}).timeout(60000);
70+
});
71+
});

tests/v1/input/urlInputSource.integration.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { describe, it } from "node:test";
12
import assert from "node:assert";
23
import { UrlInput } from "@/index.js";
34
import { Client } from "@/v1/index.js";
45
import { InvoiceV4 } from "@/v1/product/index.js";
56

6-
describe("MindeeV1 - Integration - URL Input", async () => {
7+
describe("MindeeV1 - Integration - URL Input", { timeout: 60000 }, () => {
78
it("should retrieve and parse a remote file with redirection", async () => {
89
const apiKey = process.env.MINDEE_API_KEY;
910
if (!apiKey) {
@@ -20,5 +21,5 @@ describe("MindeeV1 - Integration - URL Input", async () => {
2021
assert.strictEqual(localInput.filename, "invoice_5p.pdf");
2122
const result = await client.parse(InvoiceV4, localInput);
2223
assert.strictEqual(result.document.nPages, 5);
23-
}).timeout(60000);
24+
});
2425
});

tests/v1/workflows/workflow.integration.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { beforeEach, describe, it } from "node:test";
2+
import assert from "node:assert";
3+
import path from "path";
14
import * as mindee from "@/index.js";
25
import { ExecutionPriority } from "@/v1/parsing/common/index.js";
3-
import assert from "node:assert";
46
import { LocalInputSource } from "@/input/index.js";
57
import { OptionalAsyncOptions } from "@/v1/index.js";
68
import { FinancialDocumentV1 } from "@/v1/product/index.js";
79
import { RAGExtra } from "@/v1/parsing/common/extras/ragExtra.js";
8-
import path from "path";
910
import { V1_PRODUCT_PATH } from "../../index.js";
1011

11-
describe("MindeeV1 - Integration - Workflow calls", () => {
12+
describe("MindeeV1 - Integration - Workflow calls", { timeout: 60000 }, () => {
1213
let client: mindee.v1.Client;
1314
let sample: LocalInputSource;
1415
let workflowId: string;
@@ -33,7 +34,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
3334
{ alias: `node-${currentDateTime}`, priority: ExecutionPriority.low, rag: true });
3435
assert.strictEqual(response.execution.priority, ExecutionPriority.low);
3536
assert.strictEqual(response.execution.file.alias, `node-${currentDateTime}`);
36-
}).timeout(60000);
37+
});
3738

3839
it("should poll with RAG disabled", async () => {
3940
const asyncParams: OptionalAsyncOptions = {
@@ -46,7 +47,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
4647
);
4748
assert.ok(response.document?.toString());
4849
assert.strictEqual(response.document?.inference.extras?.rag, undefined);
49-
}).timeout(60000);
50+
});
5051

5152
it("should poll with RAG disabled and OCR words", async () => {
5253
const asyncParams: OptionalAsyncOptions = {
@@ -62,7 +63,7 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
6263
assert.strictEqual(response.document?.inference.extras?.rag, undefined);
6364
assert.ok(response.document?.ocr);
6465
assert.ok(response.document?.ocr?.toString());
65-
}).timeout(60000);
66+
});
6667

6768
it("should poll with RAG enabled", async () => {
6869
const asyncParams: OptionalAsyncOptions = {
@@ -74,10 +75,9 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
7475
sample,
7576
asyncParams
7677
);
77-
7878
assert.ok(response.document?.toString());
7979
assert.ok(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId);
80-
}).timeout(60000);
80+
});
8181

8282
it("should poll with RAG enabled and OCR words", async () => {
8383
const asyncParams: OptionalAsyncOptions = {
@@ -94,5 +94,5 @@ describe("MindeeV1 - Integration - Workflow calls", () => {
9494
assert.ok(((response.document?.inference.extras?.rag) as RAGExtra).matchingDocumentId);
9595
assert.ok(response.document?.ocr);
9696
assert.ok(response.document?.ocr?.toString());
97-
}).timeout(60000);
97+
});
9898
});

0 commit comments

Comments
 (0)