Skip to content

Commit 26f65b4

Browse files
adjust test because there is no synch execution in the test runner so there are async conflicts with other tests
1 parent afebc1d commit 26f65b4

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

v-next/hardhat/test/internal/cli/telemetry/analytics/analytics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
//
2424

2525
const PATH_TO_FIXTURE = path.join(ROOT_PATH_TO_FIXTURE, "analytics");
26-
const RESULT_FILE_PATH = path.join(PATH_TO_FIXTURE, "result.json");
26+
const RESULT_FILE_PATH = path.join(PATH_TO_FIXTURE, "analytics-result.json");
2727

2828
describe("analytics", () => {
2929
beforeEach(async () => {

v-next/hardhat/test/internal/cli/telemetry/analytics/utils.ts

+4-22
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,10 @@ import path from "node:path";
55
import { afterEach, beforeEach, describe, it } from "node:test";
66

77
import { getTelemetryDir } from "@ignored/hardhat-vnext-core/global-dir";
8-
import {
9-
readJsonFile,
10-
remove,
11-
writeJsonFile,
12-
} from "@ignored/hardhat-vnext-utils/fs";
8+
import { readJsonFile, remove } from "@ignored/hardhat-vnext-utils/fs";
139

1410
import { getAnalyticsClientId } from "../../../../../src/internal/cli/telemetry/analytics/utils.js";
1511

16-
const CLIENT_ID = "test-client-id";
17-
18-
async function createClientIdFile() {
19-
const filePath = await getFilePath();
20-
await writeJsonFile(filePath, {
21-
analytics: {
22-
clientId: CLIENT_ID,
23-
},
24-
});
25-
}
26-
2712
async function getClientIdFromFile() {
2813
const filePath = await getFilePath();
2914
const data: AnalyticsFile = await readJsonFile(filePath);
@@ -54,16 +39,13 @@ describe("telemetry/analytics/utils", () => {
5439

5540
// The analyticsClientId should be generate as uuid
5641
assert.notEqual(analyticsClientId, undefined);
57-
assert.notEqual(analyticsClientId, CLIENT_ID);
5842
// The analyticsClientId should also be saved in the file
5943
assert.equal(analyticsClientId, await getClientIdFromFile());
60-
});
6144

62-
it("should get the analyticsClientId from the file because it already exists", async () => {
63-
await createClientIdFile();
64-
const analyticsClientId = await getClientIdFromFile();
45+
const sameAnalyticsClientId = await getAnalyticsClientId();
6546

66-
assert.equal(analyticsClientId, CLIENT_ID);
47+
// The clientId should be the same if read again because it should have been stored
48+
assert.equal(sameAnalyticsClientId, analyticsClientId);
6749
});
6850
});
6951
});

0 commit comments

Comments
 (0)