diff --git a/.pnp.cjs b/.pnp.cjs index b59e49afc..ddf40fcfb 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -3475,9 +3475,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@jest/environment", "npm:29.7.0"],\ ["@jest/expect", "npm:29.7.0"],\ ["@jest/types", "npm:29.6.3"],\ - ["@types/chai", "npm:4.3.6"],\ - ["@types/chai-like", "npm:1.1.1"],\ - ["@types/chai-things", "npm:0.0.36"],\ ["@types/eslint", "npm:8.44.2"],\ ["@types/glob", "npm:8.1.0"],\ ["@types/jasmine", "npm:3.10.12"],\ @@ -3489,9 +3486,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@typescript-eslint/eslint-plugin", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:6.7.0"],\ ["@typescript-eslint/parser", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:6.7.0"],\ ["allure-js-commons", "workspace:packages/allure-js-commons"],\ - ["chai", "npm:4.3.8"],\ - ["chai-like", "virtual:606d5fd11adc18cba076ddb26a9b3adaf466a45eef985b60ea990c3ead5fe6bcc20990b0ed8d0763c4a8c861cdc2277964415bf12191df7c6923d8e78816abf5#npm:1.1.1"],\ - ["chai-things", "npm:0.2.0"],\ ["codecov", "npm:3.8.3"],\ ["eslint", "npm:8.49.0"],\ ["eslint-config-prettier", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:9.0.0"],\ @@ -3499,6 +3493,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["eslint-plugin-jsdoc", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:46.6.0"],\ ["eslint-plugin-no-null", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:1.0.2"],\ ["eslint-plugin-prefer-arrow", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:1.2.3"],\ + ["expect", "npm:29.7.0"],\ ["glob", "npm:10.3.5"],\ ["jest-circus", "npm:29.7.0"],\ ["jest-cli", "virtual:f22a73b9c1f4f0e2e1c95f149ccb41c96491085e4b2ecd3061e554432306c4df6c2976f3c6ce3a6d62abead3ccc6cf04e88b4aebf1de7356583819351e2346e2#npm:29.7.0"],\ diff --git a/packages/allure-jest/package.json b/packages/allure-jest/package.json index 520b45d8b..4f4d5440f 100644 --- a/packages/allure-jest/package.json +++ b/packages/allure-jest/package.json @@ -48,9 +48,6 @@ "@jest/core": "^29.6.2", "@jest/environment": "^29.6.4", "@jest/types": "^29.6.1", - "@types/chai": "^4.3.6", - "@types/chai-like": "^1.1.1", - "@types/chai-things": "^0.0.36", "@types/eslint": "^8", "@types/glob": "^8.1.0", "@types/jasmine": "^3.3.12", @@ -61,9 +58,6 @@ "@types/source-map-support": "^0.5.7", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", - "chai": "^4.3.8", - "chai-like": "^1.1.1", - "chai-things": "^0.2.0", "codecov": "^3.8.3", "eslint": "^8.49.0", "eslint-config-prettier": "^9.0.0", @@ -71,6 +65,7 @@ "eslint-plugin-jsdoc": "^46.6.0", "eslint-plugin-no-null": "^1.0.2", "eslint-plugin-prefer-arrow": "^1.2.3", + "expect": "^29.7.0", "glob": "^10.3.5", "jest-cli": "^29.6.2", "mocha": "^10.2.0", diff --git a/packages/allure-jest/src/AllureJest.ts b/packages/allure-jest/src/AllureJest.ts index 313fd1e86..78755b292 100644 --- a/packages/allure-jest/src/AllureJest.ts +++ b/packages/allure-jest/src/AllureJest.ts @@ -1,5 +1,6 @@ -import os from "os"; -import process from "process"; +import os from "node:os"; +import { dirname, sep } from "node:path"; +import process from "node:process"; import { EnvironmentContext, JestEnvironment, JestEnvironmentConfig } from "@jest/environment"; import type { Circus } from "@jest/types"; import { @@ -21,6 +22,7 @@ const hostname = os.hostname(); export interface AllureEnvironment extends JestEnvironment { transformLinks(links: Link[]): Link[]; + handleAllureMetadata(payload: { currentTestName: string; metadata: MetadataMessage }): void; } @@ -32,7 +34,8 @@ export interface LinkMatcher { const createJestEnvironment = (Base: T): T => { // @ts-expect-error (ts(2545)) Incorrect assumption about a mixin class: https://github.com/microsoft/TypeScript/issues/37142 return class extends Base { - testRootDirPath: string; + // testRootDirPath: string; + testPath: string; runtime: AllureRuntime; linksMatchers: LinkMatcher[]; runningTests: Map = new Map(); @@ -48,7 +51,7 @@ const createJestEnvironment = (Base: T): T => }); this.linksMatchers = links as LinkMatcher[]; this.global.allure = new AllureJestApi(this, this.global); - this.testRootDirPath = config.globalConfig.rootDir; + this.testPath = context.testPath.replace(config.globalConfig.rootDir, "").replace(sep, ""); } setup() { @@ -119,21 +122,23 @@ const createJestEnvironment = (Base: T): T => const newTestPath = newTestSuitesPath.concat(testName); const newTestId = getTestId(newTestPath); const newTest = new AllureTest(this.runtime); - const thread = ALLURE_THREAD_NAME || JEST_WORKER_ID || process.pid.toString(); - const host = ALLURE_HOST_NAME || hostname; + const threadLabel = ALLURE_THREAD_NAME || JEST_WORKER_ID || process.pid.toString(); + const hostLabel = ALLURE_HOST_NAME || hostname; + const packageLabel = dirname(this.testPath).split(sep).join("."); newTest.name = testName; newTest.fullName = newTestId; newTest.addLabel(LabelName.LANGUAGE, "javascript"); newTest.addLabel(LabelName.FRAMEWORK, "jest"); + newTest.addLabel(LabelName.PACKAGE, packageLabel); - if (thread) { - newTest.addLabel(LabelName.THREAD, thread); + if (threadLabel) { + newTest.addLabel(LabelName.THREAD, threadLabel); } - if (host) { - newTest.addLabel(LabelName.HOST, host); + if (hostLabel) { + newTest.addLabel(LabelName.HOST, hostLabel); } getSuitesLabels(newTestSuitesPath).forEach((label) => { @@ -141,13 +146,12 @@ const createJestEnvironment = (Base: T): T => }); /** - * if user have some tests with the same name, reporter will throw an - * unexpected error due the test with the same name could be removed from - * the running tests, so better to throw an explicit error + * If user have some tests with the same name, reporter will throw an error due the test with + * the same name could be removed from the running tests, so better to throw an explicit error */ if (this.runningTests.has(newTestId)) { throw new Error( - `Test "${newTestId}" has been already added to run! To continue with reporting, please rename the test.`, + `Test "${newTestId}" has been already initialized! To continue with reporting, please rename the test.`, ); } @@ -158,6 +162,12 @@ const createJestEnvironment = (Base: T): T => const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to start it!`); + return; + } + currentTest.stage = Stage.RUNNING; } @@ -165,6 +175,12 @@ const createJestEnvironment = (Base: T): T => const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to mark it as passed!`); + return; + } + currentTest.stage = Stage.FINISHED; currentTest.status = Status.PASSED; } @@ -172,6 +188,13 @@ const createJestEnvironment = (Base: T): T => private handleTestFail(test: Circus.TestEntry) { const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to mark it as failed!`); + return; + } + // jest collects all errors, but we need to report the first one because it's a reason why the test has been failed const [error] = test.errors; const hasMultipleErrors = Array.isArray(error); @@ -190,6 +213,12 @@ const createJestEnvironment = (Base: T): T => const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to mark it as skipped!`); + return; + } + currentTest.stage = Stage.PENDING; currentTest.status = Status.SKIPPED; @@ -201,6 +230,12 @@ const createJestEnvironment = (Base: T): T => const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to dispose it after start!`); + return; + } + currentTest.endTest(); this.runningTests.delete(currentTestId); } @@ -209,6 +244,12 @@ const createJestEnvironment = (Base: T): T => const currentTestId = getTestId(getTestPath(test)); const currentTest = this.runningTests.get(currentTestId)!; + if (!currentTest) { + // eslint-disable-next-line no-console + console.error(`Can't find "${currentTestId}" test while tried to mark it as todo!`); + return; + } + currentTest.stage = Stage.PENDING; currentTest.status = Status.SKIPPED; diff --git a/packages/allure-jest/test/fixtures/labels.test.js b/packages/allure-jest/test/fixtures/labels.test.js index a4a6c42af..65a5c6338 100644 --- a/packages/allure-jest/test/fixtures/labels.test.js +++ b/packages/allure-jest/test/fixtures/labels.test.js @@ -1,3 +1,5 @@ +it("package", () => {}); + it("custom", () => { allure.label("foo", "bar"); }); diff --git a/packages/allure-jest/test/runner.ts b/packages/allure-jest/test/runner.ts index f976355a7..ddb823c84 100644 --- a/packages/allure-jest/test/runner.ts +++ b/packages/allure-jest/test/runner.ts @@ -1,15 +1,8 @@ import path from "path"; -import chai from "chai"; -import chaiLike from "chai-like"; -import chaiThings from "chai-things"; import * as glob from "glob"; import Mocha from "mocha"; import "source-map-support/register"; -chai.should(); -chai.use(chaiLike); -chai.use(chaiThings); - const mocha = new Mocha({ timeout: 30000, // eslint-disable-next-line @typescript-eslint/no-require-imports diff --git a/packages/allure-jest/test/spec/ansiColors.test.ts b/packages/allure-jest/test/spec/ansiColors.test.ts index 63218e4ec..e4c5c1db8 100644 --- a/packages/allure-jest/test/spec/ansiColors.test.ts +++ b/packages/allure-jest/test/spec/ansiColors.test.ts @@ -1,4 +1,4 @@ -import { expect } from "chai"; +import expect from "expect"; import { runJestTests } from "../utils"; describe("ansiColors", () => { @@ -6,8 +6,8 @@ describe("ansiColors", () => { const results = await runJestTests(["./test/fixtures/ansiColors.test.js"]); const [result] = Object.values(results); - expect(result.name).eq("hello"); - expect(result.statusDetails.message).not.to.contain("\x1b["); - expect(result.statusDetails.trace).not.to.contain("\x1b["); + expect(result.name).toBe("hello"); + expect(result.statusDetails.message).not.toContain("\x1b["); + expect(result.statusDetails.trace).not.toContain("\x1b["); }); }); diff --git a/packages/allure-jest/test/spec/attachments.test.ts b/packages/allure-jest/test/spec/attachments.test.ts index 9f393e1af..46527b07f 100644 --- a/packages/allure-jest/test/spec/attachments.test.ts +++ b/packages/allure-jest/test/spec/attachments.test.ts @@ -1,3 +1,4 @@ +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("attachments", () => { @@ -10,9 +11,11 @@ describe("attachments", () => { it("adds markdown description", () => { const { attachments } = results.json; - attachments.should.include.something.like({ - name: "Attachment", - type: "application/json", - }); + expect(attachments).toContainEqual( + expect.objectContaining({ + name: "Attachment", + type: "application/json", + }), + ); }); }); diff --git a/packages/allure-jest/test/spec/dataTable.test.ts b/packages/allure-jest/test/spec/dataTable.test.ts index 9515cc524..2061aa70b 100644 --- a/packages/allure-jest/test/spec/dataTable.test.ts +++ b/packages/allure-jest/test/spec/dataTable.test.ts @@ -1,5 +1,5 @@ import { Stage, Status } from "allure-js-commons"; -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("each", () => { @@ -7,22 +7,27 @@ describe("each", () => { const results = await runJestTests(["./test/fixtures/dataTable.test.js"]); const values = Object.values(results); - expect(values).length(3); - - values.should.include.something.like({ - name: "1 + 2 = 3", - status: Status.PASSED, - stage: Stage.FINISHED, - }); - values.should.include.something.like({ - name: "2 + 3 = 5", - status: Status.PASSED, - stage: Stage.FINISHED, - }); - values.should.include.something.like({ - name: "3 + 4 = 7", - status: Status.PASSED, - stage: Stage.FINISHED, - }); + expect(values).toHaveLength(3); + expect(values).toContainEqual( + expect.objectContaining({ + name: "1 + 2 = 3", + status: Status.PASSED, + stage: Stage.FINISHED, + }), + ); + expect(values).toContainEqual( + expect.objectContaining({ + name: "2 + 3 = 5", + status: Status.PASSED, + stage: Stage.FINISHED, + }), + ); + expect(values).toContainEqual( + expect.objectContaining({ + name: "3 + 4 = 7", + status: Status.PASSED, + stage: Stage.FINISHED, + }), + ); }); }); diff --git a/packages/allure-jest/test/spec/description.test.ts b/packages/allure-jest/test/spec/description.test.ts index 7a836862a..0d87e0624 100644 --- a/packages/allure-jest/test/spec/description.test.ts +++ b/packages/allure-jest/test/spec/description.test.ts @@ -1,4 +1,4 @@ -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("description", () => { @@ -11,12 +11,12 @@ describe("description", () => { it("adds markdown description", () => { const { description } = results.markdown; - expect(description).eq("foo"); + expect(description).toBe("foo"); }); it("adds custom history id", () => { const { descriptionHtml } = results.html; - expect(descriptionHtml).eq("foo"); + expect(descriptionHtml).toBe("foo"); }); }); diff --git a/packages/allure-jest/test/spec/duplicatedTests.test.ts b/packages/allure-jest/test/spec/duplicatedTests.test.ts index a7f6a57c5..6d0314778 100644 --- a/packages/allure-jest/test/spec/duplicatedTests.test.ts +++ b/packages/allure-jest/test/spec/duplicatedTests.test.ts @@ -1,16 +1,10 @@ -import { expect } from "chai"; +import expect from "expect"; import { runJestTests } from "../utils"; describe("tests with the same name", () => { it("throws an user-friendly error", async () => { - try { - await runJestTests(["./test/fixtures/duplicatedTests.test.js"]); - } catch (err) { - // @ts-ignore - expect(err.message).eq( - // eslint-disable-next-line @typescript-eslint/quotes - 'Test "has the same name" has been already added to run! To continue with reporting, please rename the test.', - ); - } + await expect(() => runJestTests(["./test/fixtures/duplicatedTests.test.js"])).rejects.toThrow( + 'Test "has the same name" has been already initialized! To continue with reporting, please rename the test.', + ); }); }); diff --git a/packages/allure-jest/test/spec/historyId.test.ts b/packages/allure-jest/test/spec/historyId.test.ts index f09a28e40..059d3b903 100644 --- a/packages/allure-jest/test/spec/historyId.test.ts +++ b/packages/allure-jest/test/spec/historyId.test.ts @@ -1,4 +1,4 @@ -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("historyId", () => { @@ -11,6 +11,6 @@ describe("historyId", () => { it("adds custom history id", () => { const { historyId } = results.historyId; - expect(historyId).eq("foo"); + expect(historyId).toBe("foo"); }); }); diff --git a/packages/allure-jest/test/spec/labels.test.ts b/packages/allure-jest/test/spec/labels.test.ts index a35773482..0d613047f 100644 --- a/packages/allure-jest/test/spec/labels.test.ts +++ b/packages/allure-jest/test/spec/labels.test.ts @@ -1,4 +1,6 @@ +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; +import { LabelName } from "allure-js-commons"; describe("labels", () => { let results: TestResultsByFullName; @@ -7,102 +9,135 @@ describe("labels", () => { results = await runJestTests(["./test/fixtures/labels.test.js"]); }); + it("adds package label", () => { + const { labels } = results.package; + + expect(labels).toContainEqual( + expect.objectContaining({ + name: LabelName.PACKAGE, + value: "fixtures", + }), + ); + }); + it("adds custom label", () => { const { labels } = results.custom; - labels.should.include.something.that.deep.equals({ - name: "foo", - value: "bar", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "foo", + value: "bar", + }), + ); }); it("adds allureId label", () => { const { labels } = results.allureId; - labels.should.include.something.that.deep.equals({ - name: "ALLURE_ID", - value: "42", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "ALLURE_ID", + value: "42", + }), + ); }); it("adds epic label", () => { const { labels } = results.epic; - labels.should.include.something.that.deep.equals({ - name: "epic", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "epic", + value: "foo", + }), + ); }); it("adds owner label", () => { const { labels } = results.owner; - labels.should.include.something.that.deep.equals({ - name: "owner", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "owner", + value: "foo", + }), + ); }); it("adds parentSuite label", () => { const { labels } = results.parentSuite; - labels.should.include.something.that.deep.equals({ - name: "parentSuite", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "parentSuite", + value: "foo", + }), + ); }); it("adds subSuite label", () => { const { labels } = results.subSuite; - labels.should.include.something.that.deep.equals({ - name: "subSuite", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "subSuite", + value: "foo", + }), + ); }); it("adds severity label", () => { const { labels } = results.severity; - labels.should.include.something.that.deep.equals({ - name: "severity", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "severity", + value: "foo", + }), + ); }); it("adds story label", () => { const { labels } = results.story; - labels.should.include.something.that.deep.equals({ - name: "story", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "story", + value: "foo", + }), + ); }); it("adds suite label", () => { const { labels } = results.suite; - labels.should.include.something.that.deep.equals({ - name: "suite", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "suite", + value: "foo", + }), + ); }); it("adds tag label", () => { const { labels } = results.tag; - labels.should.include.something.that.deep.equals({ - name: "tag", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "tag", + value: "foo", + }), + ); }); it("adds feature label", () => { const { labels } = results.feature; - labels.should.include.something.that.deep.equals({ - name: "feature", - value: "foo", - }); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "feature", + value: "foo", + }), + ); }); }); diff --git a/packages/allure-jest/test/spec/links.test.ts b/packages/allure-jest/test/spec/links.test.ts index 5eff93ece..515bc265d 100644 --- a/packages/allure-jest/test/spec/links.test.ts +++ b/packages/allure-jest/test/spec/links.test.ts @@ -1,3 +1,4 @@ +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; /** @@ -13,30 +14,36 @@ describe("links", () => { it("adds custom link", () => { const { links } = results.custom; - links.should.include.something.that.deep.equals({ - type: "foo", - name: "bar", - url: "http://example.org", - }); + expect(links).toContainEqual( + expect.objectContaining({ + type: "foo", + name: "bar", + url: "http://example.org", + }), + ); }); it("adds tms link", () => { const { links } = results.tms; - links.should.include.something.that.deep.equals({ - type: "tms", - name: "foo", - url: "http://example.org/tasks/1", - }); + expect(links).toContainEqual( + expect.objectContaining({ + type: "tms", + name: "foo", + url: "http://example.org/tasks/1", + }), + ); }); it("adds issue link", () => { const { links } = results.issue; - links.should.include.something.that.deep.equals({ - type: "issue", - name: "foo", - url: "http://example.org/issues/1", - }); + expect(links).toContainEqual( + expect.objectContaining({ + type: "issue", + name: "foo", + url: "http://example.org/issues/1", + }), + ); }); }); diff --git a/packages/allure-jest/test/spec/parameters.test.ts b/packages/allure-jest/test/spec/parameters.test.ts index 7567b2fd4..407a516e5 100644 --- a/packages/allure-jest/test/spec/parameters.test.ts +++ b/packages/allure-jest/test/spec/parameters.test.ts @@ -1,3 +1,4 @@ +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("parameters", () => { @@ -10,11 +11,13 @@ describe("parameters", () => { it("adds custom parameter", () => { const { parameters } = results.custom; - parameters.should.include.something.that.deep.equals({ - name: "foo", - value: "bar", - excluded: false, - mode: "hidden", - }); + expect(parameters).toContainEqual( + expect.objectContaining({ + name: "foo", + value: "bar", + excluded: false, + mode: "hidden", + }), + ); }); }); diff --git a/packages/allure-jest/test/spec/skipped.test.ts b/packages/allure-jest/test/spec/skipped.test.ts index 91bbafa73..f09ef79e7 100644 --- a/packages/allure-jest/test/spec/skipped.test.ts +++ b/packages/allure-jest/test/spec/skipped.test.ts @@ -1,5 +1,5 @@ import { Stage, Status } from "allure-js-commons"; -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("skipped", () => { @@ -12,14 +12,14 @@ describe("skipped", () => { it("marks skipped test as skipped", () => { const { stage, status } = results.skipped; - expect(stage).eq(Stage.PENDING); - expect(status).eq(Status.SKIPPED); + expect(stage).toBe(Stage.PENDING); + expect(status).toBe(Status.SKIPPED); }); it("marks test inside skipped suite as skipped", () => { const { stage, status } = results["suite skipped"]; - expect(stage).eq(Stage.PENDING); - expect(status).eq(Status.SKIPPED); + expect(stage).toBe(Stage.PENDING); + expect(status).toBe(Status.SKIPPED); }); }); diff --git a/packages/allure-jest/test/spec/steps.test.ts b/packages/allure-jest/test/spec/steps.test.ts index c2b1fd94a..79193759b 100644 --- a/packages/allure-jest/test/spec/steps.test.ts +++ b/packages/allure-jest/test/spec/steps.test.ts @@ -1,5 +1,5 @@ import { Status } from "allure-js-commons"; -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("steps", () => { @@ -13,17 +13,18 @@ describe("steps", () => { it("adds nested steps", () => { const { steps, labels } = results.passed; - labels.should.include.something.that.deep.equals({ - name: "foo", - value: "bar", - }); - - expect(steps.length).eq(1); - expect(steps[0].name).eq("first step name"); - expect(steps[0].steps.length).eq(1); - expect(steps[0].steps[0].name).eq("second step name"); - expect(steps[0].steps[0].steps.length).eq(1); - expect(steps[0].steps[0].steps[0].name).eq("third step name"); + expect(labels).toContainEqual( + expect.objectContaining({ + name: "foo", + value: "bar", + }), + ); + expect(steps.length).toBe(1); + expect(steps[0].name).toBe("first step name"); + expect(steps[0].steps.length).toBe(1); + expect(steps[0].steps[0].name).toBe("second step name"); + expect(steps[0].steps[0].steps.length).toBe(1); + expect(steps[0].steps[0].steps[0].name).toBe("third step name"); }); }); @@ -31,20 +32,20 @@ describe("steps", () => { it("fails the test with original step error", () => { const { status, statusDetails, steps } = results.failed; - expect(status).eq(Status.FAILED); - expect(statusDetails.message).eq("foo"); - expect(steps).to.have.length(1); - expect(steps[0].name).eq("first step name"); - expect(steps[0].status).eq(Status.BROKEN); - expect(steps[0].statusDetails.message).eq("foo"); - expect(steps[0].steps.length).eq(1); - expect(steps[0].steps[0].name).eq("second step name"); - expect(steps[0].steps[0].status).eq(Status.BROKEN); - expect(steps[0].steps[0].statusDetails.message).eq("foo"); - expect(steps[0].steps[0].steps.length).eq(1); - expect(steps[0].steps[0].steps[0].name).eq("third step name"); - expect(steps[0].steps[0].steps[0].status).eq(Status.BROKEN); - expect(steps[0].steps[0].steps[0].statusDetails.message).eq("foo"); + expect(status).toBe(Status.FAILED); + expect(statusDetails.message).toBe("foo"); + expect(steps).toHaveLength(1); + expect(steps[0].name).toBe("first step name"); + expect(steps[0].status).toBe(Status.BROKEN); + expect(steps[0].statusDetails.message).toBe("foo"); + expect(steps[0].steps.length).toBe(1); + expect(steps[0].steps[0].name).toBe("second step name"); + expect(steps[0].steps[0].status).toBe(Status.BROKEN); + expect(steps[0].steps[0].statusDetails.message).toBe("foo"); + expect(steps[0].steps[0].steps.length).toBe(1); + expect(steps[0].steps[0].steps[0].name).toBe("third step name"); + expect(steps[0].steps[0].steps[0].status).toBe(Status.BROKEN); + expect(steps[0].steps[0].steps[0].statusDetails.message).toBe("foo"); }); }); }); diff --git a/packages/allure-jest/test/spec/testCaseId.test.ts b/packages/allure-jest/test/spec/testCaseId.test.ts index 2ef0e89dc..d2e68d19a 100644 --- a/packages/allure-jest/test/spec/testCaseId.test.ts +++ b/packages/allure-jest/test/spec/testCaseId.test.ts @@ -1,4 +1,4 @@ -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("testCaseId", () => { @@ -11,6 +11,6 @@ describe("testCaseId", () => { it("adds custom history id", () => { const { testCaseId } = results.testCaseId; - expect(testCaseId).eq("foo"); + expect(testCaseId).toBe("foo"); }); }); diff --git a/packages/allure-jest/test/spec/todo.test.ts b/packages/allure-jest/test/spec/todo.test.ts index 71d47027e..4a53eceab 100644 --- a/packages/allure-jest/test/spec/todo.test.ts +++ b/packages/allure-jest/test/spec/todo.test.ts @@ -1,5 +1,5 @@ import { Stage, Status } from "allure-js-commons"; -import { expect } from "chai"; +import expect from "expect"; import { runJestTests, TestResultsByFullName } from "../utils"; describe("todo", () => { @@ -12,7 +12,7 @@ describe("todo", () => { it("marks todo tests as skipped", () => { const { stage, status } = results.todo; - expect(stage).eq(Stage.PENDING); - expect(status).eq(Status.SKIPPED); + expect(stage).toBe(Stage.PENDING); + expect(status).toBe(Status.SKIPPED); }); }); diff --git a/yarn.lock b/yarn.lock index c3e949c1b..8497501c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2584,9 +2584,6 @@ __metadata: "@jest/environment": ^29.6.4 "@jest/expect": ^29.6.2 "@jest/types": ^29.6.1 - "@types/chai": ^4.3.6 - "@types/chai-like": ^1.1.1 - "@types/chai-things": ^0.0.36 "@types/eslint": ^8 "@types/glob": ^8.1.0 "@types/jasmine": ^3.3.12 @@ -2598,9 +2595,6 @@ __metadata: "@typescript-eslint/eslint-plugin": ^6.7.0 "@typescript-eslint/parser": ^6.7.0 allure-js-commons: "workspace:*" - chai: ^4.3.8 - chai-like: ^1.1.1 - chai-things: ^0.2.0 codecov: ^3.8.3 eslint: ^8.49.0 eslint-config-prettier: ^9.0.0 @@ -2608,6 +2602,7 @@ __metadata: eslint-plugin-jsdoc: ^46.6.0 eslint-plugin-no-null: ^1.0.2 eslint-plugin-prefer-arrow: ^1.2.3 + expect: ^29.7.0 glob: ^10.3.5 jest-circus: ^29.6.2 jest-cli: ^29.6.2