Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(allure-codeceptjs): rework codeceptjs integration #1107

Merged
merged 7 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading