-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecord.test.ts
More file actions
51 lines (44 loc) · 1.53 KB
/
record.test.ts
File metadata and controls
51 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { describe, it, expect, afterEach } from "vitest";
import { record } from "../src/index";
import { Algodv2 } from "algosdk";
import fs from "fs";
import path from "path";
const TEST_RECORDINGS_DIR = path.resolve(__dirname, "../recordings-test");
describe("Recording Tests", () => {
afterEach(async () => {
// Clean up test recordings directory completely
if (fs.existsSync(TEST_RECORDINGS_DIR)) {
fs.rmSync(TEST_RECORDINGS_DIR, { recursive: true, force: true });
}
});
it("should record in record-new mode", async () => {
// Create test recordings directory
fs.mkdirSync(TEST_RECORDINGS_DIR, { recursive: true });
// Create recording with record-new using TestNet
await record(
"algod",
async () => {
const algod = new Algodv2(
"a".repeat(64),
"https://testnet-api.4160.nodely.dev",
443
);
await algod.status().do();
},
"record-new",
TEST_RECORDINGS_DIR
);
// Verify HAR file was created
const harFiles = fs.readdirSync(TEST_RECORDINGS_DIR, { recursive: true });
const harFileName = harFiles.find((f) =>
f.toString().endsWith("recording.har")
);
expect(harFileName).toBeDefined();
const harPath = path.join(TEST_RECORDINGS_DIR, harFileName!.toString());
expect(fs.existsSync(harPath)).toBe(true);
// Verify HAR file has entries
const content = fs.readFileSync(harPath, "utf-8");
const har = JSON.parse(content);
expect(har.log.entries.length).toBeGreaterThan(0);
});
});