Skip to content

Commit 8194898

Browse files
committed
fix: test race condition with template downloading that caused random failures
1 parent 2c23d48 commit 8194898

File tree

2 files changed

+42
-56
lines changed

2 files changed

+42
-56
lines changed

test/asyncapi/build-docs.integration.test.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

test/asyncapi/generate/from-template.integration.test.ts

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,33 @@ describe("AsyncAPI From-Template Integration Tests", () => {
1818
});
1919

2020
describe("HTML template generation", () => {
21-
it("should generate HTML documentation from simple spec", () => {
22-
fs.cpSync(
23-
path.join(originalCwd, "test/fixtures/asyncapi/valid/simple-spec"),
24-
path.join(tempDir, "asyncapi"),
25-
{ recursive: true },
26-
);
27-
28-
const result = runCli([
29-
"asyncapi",
30-
"generate",
31-
"from-template",
32-
"@asyncapi/html-template",
33-
"asyncapi/asyncapi.yaml",
34-
"--silent",
35-
]);
36-
37-
expect(result.exitCode).toBe(0);
38-
expect(fs.existsSync("dist/generated")).toBe(true);
39-
40-
// html template generates index.html, css/* and js/* files
41-
const generatedFiles = fs.readdirSync("dist/generated");
42-
expect(generatedFiles.length).toBeGreaterThan(0);
43-
});
21+
it(
22+
"should generate HTML documentation from simple spec",
23+
{ timeout: 120_000 },
24+
() => {
25+
fs.cpSync(
26+
path.join(originalCwd, "test/fixtures/asyncapi/valid/simple-spec"),
27+
path.join(tempDir, "asyncapi"),
28+
{ recursive: true },
29+
);
30+
31+
const result = runCli([
32+
"asyncapi",
33+
"generate",
34+
"from-template",
35+
"@asyncapi/html-template",
36+
"asyncapi/asyncapi.yaml",
37+
"--silent",
38+
]);
39+
40+
expect(result.exitCode).toBe(0);
41+
expect(fs.existsSync("dist/generated")).toBe(true);
42+
43+
// html template generates index.html, css/* and js/* files
44+
const generatedFiles = fs.readdirSync("dist/generated");
45+
expect(generatedFiles.length).toBeGreaterThan(0);
46+
},
47+
);
4448
});
4549

4650
describe("default input handling", () => {
@@ -266,4 +270,19 @@ describe("AsyncAPI From-Template Integration Tests", () => {
266270
expect(fs.existsSync(path.join(subDir, "dist/generated"))).toBe(true);
267271
});
268272
});
273+
274+
describe("command aliases", () => {
275+
it("should work as top-level build-docs command", () => {
276+
fs.cpSync(
277+
path.join(originalCwd, "test/fixtures/asyncapi/valid/simple-spec"),
278+
path.join(tempDir, "asyncapi"),
279+
{ recursive: true },
280+
);
281+
282+
const result = runCli(["asyncapi", "build-docs", "--silent"]);
283+
284+
expect(result.exitCode).toBe(0);
285+
expect(fs.existsSync("dist/docs/asyncapi.html")).toBe(true);
286+
});
287+
});
269288
});

0 commit comments

Comments
 (0)