Skip to content

Commit

Permalink
add legacy api fixtures for mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed May 31, 2024
1 parent 82922dd commit 050be2e
Show file tree
Hide file tree
Showing 54 changed files with 836 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/allure-mocha/src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LegacyAllureApi {
subSuite = (name: string) => Promise.resolve(commons.subSuite(name));
label = (name: string, value: string) => Promise.resolve(commons.label(name, value));
parameter = (name: string, value: any, options?: ParameterOptions) =>
Promise.resolve(commons.parameter(name, serialize(value), options));
Promise.resolve(commons.parameter(name, serialize(value) as string, options));
link = (url: string, name?: string, type?: string) => Promise.resolve(commons.link(url, type, name));
issue = (name: string, url: string) => Promise.resolve(commons.issue(url, name));
tms = (name: string, url: string) => Promise.resolve(commons.tms(url, name));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// cjs: const { Status } = require("allure-js-commons");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";
// esm: import { Status } from "allure-js-commons";

it("a test run with categories", () => {
allure.writeCategoriesDefinitions([
{
name: "foo",
description: "bar",
messageRegex: "broken",
matchedStatuses: [Status.BROKEN],
},
{
name: "baz",
description: "qux",
messageRegex: "failure",
matchedStatuses: [Status.FAILED],
},
]);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a description", () => {
allure.description("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a description in HTML", () => {
allure.descriptionHtml("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("a test run with env info", () => {
allure.writeEnvironmentInfo({ foo: "bar", baz: "qux" });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { beforeEach, describe, it } from "mocha";
import { allure } from "allure-mocha/runtime";

describe("a suite with before", () => {
beforeEach("an initial name", () => {
allure.displayName("a new name");
});

it("a test affected by a renamed fixture", () => {});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with an epic", () => {
allure.epic("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a feature", () => {
allure.feature("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a story", () => {
allure.story("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a custom label", () => {
allure.label("foo", "bar");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a layer", () => {
allure.layer("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with an owner", () => {
allure.owner("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a blocker", () => {
allure.severity("blocker");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a critical test", () => {
allure.severity("critical");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a minor test", () => {
allure.severity("minor");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a normal test", () => {
allure.severity("normal");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a trivial test", () => {
allure.severity("trivial");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a parent suite", () => {
allure.parentSuite("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a sub-suite", () => {
allure.subSuite("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a suite", () => {
allure.suite("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with tags", () => {
allure.tag("foo");
allure.tag("bar");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with an issue link", () => {
allure.issue("baz", "https://foo.bar");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a named link", () => {
allure.link("https://foo.bar", "baz");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a tms link", () => {
allure.tms("baz", "https://foo.bar");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a url only link", () => {
allure.link("https://foo.bar");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a link of a custom type", () => {
allure.link("https://foo.bar", "baz", "qux");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

["bar", "baz"].forEach((v) => {
it("a test with an excluded parameter", () => {
allure.parameter("foo", v, { excluded: true });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a hidden parameter", () => {
allure.parameter("foo", "bar", { mode: "hidden" });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a test with a masked parameter", () => {
allure.parameter("foo", "bar", { mode: "masked" });
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

["bar", "baz", { key: 10 }].forEach((v) => {
it("a test with a parameter", () => {
allure.parameter("foo", v);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// cjs: const { Status } = require("allure-js-commons");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";
// esm: import { Status } from "allure-js-commons";

it("a broken log step", () => {
allure.logStep("foo", Status.BROKEN);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a broken step", () => {
allure.step("foo", () => {
throw new Error("foo");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// cjs: const { Status } = require("allure-js-commons");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";
// esm: import { Status } from "allure-js-commons";

it("a failed log step", () => {
allure.logStep("foo", Status.FAILED);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect } from "chai";
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a failed step", () => {
allure.step("foo", () => {
expect("foo").eq("bar", "baz");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a lambda step", () => {
allure.step("foo", () => {});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a log step", () => {
allure.step("foo");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("a test with a renamed step", () => {
allure.step("foo", (ctx) => {
ctx.name("bar");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// cjs: const { Status } = require("allure-js-commons");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";
// esm: import { Status } from "allure-js-commons";

it("a skipped log step", () => {
allure.logStep("foo", Status.SKIPPED);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("a test with a step that returns a value promise", async () => {
const result = await allure.step("foo", async () => await new Promise((r) => setTimeout(() => r("bar"), 50)));
if (result !== "bar") {
throw new Error(`Unexpected value ${result}`);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("a test with a step that returns a value", () => {
const result = allure.step("foo", () => "bar");
if (result !== "bar") {
throw new Error(`Unexpected value ${result}`);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("a step with an attachment", () => {
allure.step("step", () => {
allure.attachment("foo.txt", Buffer.from("bar"), "text/plain");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("a step with a parameter", () => {
allure.step("foo", (ctx) => {
ctx.parameter("bar", "baz");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("two nested steps", () => {
allure.step("foo", () => {
allure.step("bar", () => {});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("two steps in a row", () => {
allure.step("foo", () => {});
allure.step("bar", () => {});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { it } from "mocha";
import { allure } from "allure-mocha/runtime";

it("test attachment", () => {
allure.attachment("foo.txt", Buffer.from("bar"), "text/plain");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cjs: const { it } = require("mocha");
// cjs: const { allure } = require("allure-mocha/runtime");
// esm: import { it } from "mocha";
// esm: import { allure } from "allure-mocha/runtime";

it("testAttachment from a step", () => {
allure.step("foo", () => {
allure.testAttachment("bar.txt", Buffer.from("baz"), "text/plain");
});
});
Loading

0 comments on commit 050be2e

Please sign in to comment.