Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: add missing reporter resilience #33

Merged
merged 1 commit into from
Feb 17, 2024
Merged
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
18 changes: 16 additions & 2 deletions src/realms/AllureRealm.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import path from 'node:path';
import os from 'node:os';

import { state } from 'jest-metadata';
import type { AllureGlobalMetadata } from 'jest-allure2-reporter';

Expand All @@ -12,15 +15,26 @@ export class AllureRealm {
getGlobalMetadata: () => state,
getNow: () => Date.now(),
getReporterConfig() {
const config = new AllureMetadataProxy<AllureGlobalMetadata>(state).get(
let config = new AllureMetadataProxy<AllureGlobalMetadata>(state).get(
'config',
);
if (!config) {
throw new Error(
console.warn(
"Cannot receive jest-allure2-reporter's config from the parent process. Have you set up Jest test environment correctly?",
);
}

config ??= {
resultsDir: path.join(os.tmpdir(), 'allure-results'),
overwrite: true,
injectGlobals: true,
attachments: {
subDir: 'attachments',
contentHandler: 'write',
fileHandler: 'ref',
},
};

return config as SharedReporterConfig;
},
});
Expand Down
Loading