Skip to content

Commit

Permalink
feat(allure-codeceptjs): rework codeceptjs integration (via #1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
baev authored Aug 9, 2024
1 parent 4fb78e9 commit 60767e9
Show file tree
Hide file tree
Showing 30 changed files with 1,142 additions and 476 deletions.
50 changes: 44 additions & 6 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/allure-codeceptjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"test": "vitest run"
},
"dependencies": {
"allure-js-commons": "workspace:*"
"allure-js-commons": "workspace:*",
"allure-mocha": "workspace:*"
},
"devDependencies": {
"@babel/cli": "^7.24.6",
Expand Down
28 changes: 0 additions & 28 deletions packages/allure-codeceptjs/src/helpers.ts

This file was deleted.

20 changes: 12 additions & 8 deletions packages/allure-codeceptjs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { container } from "codeceptjs";
import { attachment } from "allure-js-commons";
import type { ReporterConfig } from "allure-js-commons/sdk/reporter";
import { setGlobalTestRuntime } from "allure-js-commons/sdk/runtime";
import { allureCodeceptJsLegacyApi } from "./legacy.js";
import { AllureCodeceptJsReporter } from "./reporter.js";
import { AllureCodeceptJsTestRuntime } from "./runtime.js";

const allurePlugin = (config: ReporterConfig) => {
const reporter = new AllureCodeceptJsReporter(config);
const testRuntime = new AllureCodeceptJsTestRuntime(reporter);
const mocha = container.mocha();
mocha.reporter(AllureCodeceptJsReporter.prototype.constructor, { ...config });

// @ts-ignore
setGlobalTestRuntime(testRuntime);

return allureCodeceptJsLegacyApi;
return {
...allureCodeceptJsLegacyApi,
// this method is used by various bundled codeceptjs plugins, e.g. by screenshotOnFail
addAttachment: (name: string, content: Buffer | string, contentType: string) => {
// wrap it in attachmentStep. Since we use Mocha, Runtime API is sync, so no awaits is fine
attachment(name, content, contentType);
},
};
};

export default allurePlugin;
4 changes: 0 additions & 4 deletions packages/allure-codeceptjs/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ export interface CodeceptStep {
metaStep: CodeceptStep;
toString: () => string;
}

export type CodeceptHook = Mocha.Hook;

export type CodeceptTest = Mocha.Runnable;
Loading

0 comments on commit 60767e9

Please sign in to comment.