Skip to content

Commit

Permalink
perf: improve bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Dec 19, 2022
1 parent b72565c commit 74a590a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jest-allure2-reporter",
"version": "1.0.0",
"description": "TODO: describe reporter",
"description": "Idiomatic Jest reporter for Allure Framework",
"license": "MIT",
"keywords": [
"allure",
Expand Down Expand Up @@ -73,6 +73,7 @@
"jest": "^28.1.1",
"jest-environment-node": "^28.1.2",
"lint-staged": "^13.0.3",
"lodash": "^4.17.21",
"prettier": "^2.7.1",
"semantic-release": "^19.0.3",
"tempfile": "^3.0.0",
Expand All @@ -84,7 +85,6 @@
},
"dependencies": {
"allure-js-commons": "^2.0.0-beta.19",
"lodash": "^4.17.21",
"pkg-up": "^3.1.0",
"rimraf": "^3.0.2",
"strip-ansi": "^6.0.0"
Expand Down
5 changes: 2 additions & 3 deletions src/context/TestRunContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'path';

import { mapValues } from 'lodash';
// eslint-disable-next-line node/no-unpublished-import
import type { Test, TestResult } from '@jest/reporters';

Expand All @@ -27,11 +26,11 @@ export default class TestRunContext {
runtime.writeCategoriesDefinitions([]);
}

async _getEnvironmentInfo() {
async _getEnvironmentInfo(): Promise<any> {
const { getEnvironmentInfo } = this._config;

if (typeof getEnvironmentInfo === 'boolean') {
return getEnvironmentInfo ? mapValues(process.env, String) : {};
return getEnvironmentInfo ? process.env : {};
}

return getEnvironmentInfo();
Expand Down
7 changes: 5 additions & 2 deletions src/selectors/testCase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from 'path';

import { Status } from 'allure-js-commons';
import { isEmpty } from 'lodash';
import stripAnsi from 'strip-ansi';
// eslint-disable-next-line node/no-unpublished-import
import type { TestCaseResult } from '@jest/reporters';
Expand All @@ -17,6 +16,9 @@ import type {
TimeService,
} from './fallbacks';

const isEmptyObject = (value: unknown) =>
value && typeof value === 'object' && Object.keys(value).length === 0;

type Services = {
reporterOptions: Partial<JestAllure2ReporterOptions>;
meta: MetadataService;
Expand Down Expand Up @@ -100,7 +102,8 @@ export class TestCaseSelectors {
if (this._services.reporterOptions.errorsAsFailedAssertions) {
return Status.FAILED;
} else {
const hasUnhandledErrors = testCaseResult.failureDetails.some((item) => isEmpty(item));
// eslint-disable-next-line unicorn/no-array-callback-reference
const hasUnhandledErrors = testCaseResult.failureDetails.some(isEmptyObject);
return hasUnhandledErrors ? Status.BROKEN : Status.FAILED;
}
case 'pending':
Expand Down

0 comments on commit 74a590a

Please sign in to comment.