-
-
Notifications
You must be signed in to change notification settings - Fork 348
/
Copy pathoverridePreset.test.ts
35 lines (28 loc) · 1.28 KB
/
overridePreset.test.ts
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
import path from "node:path";
import util from "node:util";
import child from "node:child_process";
import {fileURLToPath} from "node:url";
import {describe, it, expect, vi} from "vitest";
const scriptNames = {
ok: "overridePresetOk.ts",
error: "overridePresetError.ts",
};
const exec = util.promisify(child.exec);
// Global variable __dirname no longer available in ES6 modules.
// Solutions: https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = path.dirname(fileURLToPath(import.meta.url));
describe("Override preset", function () {
// Allow time for ts-node to compile Typescript source
vi.setConfig({testTimeout: 30_000});
it("Should correctly override preset", async () => {
// These commands can not run with minimal preset
if (process.env.LODESTAR_PRESET === "minimal") delete process.env.LODESTAR_PRESET;
await exec(`node --loader ts-node/esm ${path.join(__dirname, scriptNames.ok)}`);
});
it("Should throw trying to override preset in the wrong order", async () => {
await expect(exec(`node --loader ts-node/esm ${path.join(__dirname, scriptNames.error)}`)).rejects.toThrow(
"Lodestar preset is already frozen"
);
});
});