-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,45 @@ | ||
import type { AllureStaticServer } from "@allurereport/static-server"; | ||
import { serve } from "@allurereport/static-server"; | ||
import { expect, test } from "@playwright/test"; | ||
import { layer } from "allure-js-commons"; | ||
import { Stage, Status } from "allure-js-commons"; | ||
import { mkdtemp, rm } from "node:fs/promises"; | ||
import { tmpdir } from "node:os"; | ||
import { resolve } from "node:path"; | ||
import { generateTestResults } from "../utils/index.js"; | ||
|
||
let server: AllureStaticServer; | ||
let host: string; | ||
let allureTestResultsDir: string; | ||
let allureReportDir: string; | ||
|
||
test.beforeAll(async () => { | ||
const now = Date.now(); | ||
const temp = tmpdir(); | ||
|
||
allureTestResultsDir = await mkdtemp(resolve(temp, "allure-results-")); | ||
allureReportDir = await mkdtemp(resolve(temp, "allure-report-")); | ||
|
||
await generateTestResults({ | ||
reportConfig: { | ||
name: "Sample allure report" | ||
import { type ReportBootstrap, boostrapReport } from "../utils/index.js"; | ||
|
||
let bootstrap: ReportBootstrap; | ||
|
||
const now = Date.now(); | ||
const fixtures = { | ||
testResults: [ | ||
{ | ||
name: "0 sample passed test", | ||
fullName: "sample.js#0 sample passed test", | ||
status: Status.PASSED, | ||
stage: Stage.FINISHED, | ||
start: now, | ||
stop: now + 1000, | ||
}, | ||
resultsDir: allureTestResultsDir, | ||
reportDir: allureReportDir, | ||
testResults: [ | ||
{ | ||
name: "0 sample passed test", | ||
fullName: "sample.js#0 sample passed test", | ||
status: Status.PASSED, | ||
stage: Stage.FINISHED, | ||
start: now, | ||
stop: now + 1000, | ||
}, | ||
] | ||
}); | ||
|
||
server = await serve({ | ||
servePath: resolve(allureReportDir, "./awesome"), | ||
}); | ||
host = `http://localhost:${server.port}`; | ||
}); | ||
], | ||
}; | ||
|
||
test.afterAll(async () => { | ||
try { | ||
await rm(allureTestResultsDir, { recursive: true }); | ||
await rm(allureReportDir, { recursive: true }); | ||
} catch (ignored) {} | ||
|
||
await server?.stop(); | ||
await bootstrap?.shutdown?.(); | ||
}); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
test.beforeEach(async () => { | ||
await layer("e2e"); | ||
await page.goto(host); | ||
}); | ||
|
||
test.describe("allure-awesome", () => { | ||
test.describe("report options", () => { | ||
test("report title and page title contain give report name", async ({ page }) => { | ||
bootstrap = await boostrapReport({ | ||
reportConfig: { | ||
name: "Sample allure report", | ||
}, | ||
testResults: fixtures.testResults, | ||
}); | ||
await page.goto(bootstrap.url); | ||
|
||
await expect(page.getByTestId("report-title")).toHaveText("Sample allure report"); | ||
expect(await page.title()).toBe("Sample allure report"); | ||
}); | ||
}) | ||
}) | ||
|
||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.