Skip to content

Commit

Permalink
feat(utils): implement report.md formatting (#196)
Browse files Browse the repository at this point in the history
Implemented the changes for the report.md file formatting.
Added the following sections: Overview, Categories, Audits, About.
Closes #148
  • Loading branch information
MishaSeredenkoPushBased committed Nov 6, 2023
1 parent 05c09ea commit 346596d
Show file tree
Hide file tree
Showing 15 changed files with 727 additions and 505 deletions.
4 changes: 2 additions & 2 deletions e2e/cli-e2e/tests/collect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('CLI collect', () => {

const md = await readTextFile('tmp/react-todos-app/report.md');

expect(md).toContain('# Code Pushup Report');
expect(md).toContain('# Code PushUp Report');
expect(md).toContain(exampleCategoryTitle);
expect(md).toContain(exampleAuditTitle);
});
Expand All @@ -82,7 +82,7 @@ describe('CLI collect', () => {
expect(code).toBe(0);
expect(stderr).toBe('');

expect(stdout).toContain('Code Pushup Report');
expect(stdout).toContain('Code PushUp Report');
expect(stdout).toContain('Generated reports');
expect(stdout).toContain('report.json');
expect(stdout).toContain(exampleCategoryTitle);
Expand Down
1 change: 1 addition & 0 deletions global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export async function setup() {
// ensure clean tmp/ directory
await rm('tmp', { recursive: true, force: true });
await mkdir('tmp', { recursive: true });
process.env.TZ = 'UTC';
}
12 changes: 8 additions & 4 deletions packages/core/src/lib/implementation/persist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {
minimalReport,
persistConfig,
} from '@code-pushup/models/testing';
import { CODE_PUSHUP_DOMAIN, FOOTER_PREFIX } from '@code-pushup/utils';
import {
CODE_PUSHUP_DOMAIN,
FOOTER_PREFIX,
README_LINK,
} from '@code-pushup/utils';
import { mockConsole, unmockConsole } from '../../../test/console.mock';
import { logPersistedResults, persistReport } from './persist';

Expand Down Expand Up @@ -113,7 +117,7 @@ describe('persistReport', () => {
});
const mdReport = readFileSync(reportPath('md')).toString();
expect(mdReport).toContain(
`${FOOTER_PREFIX} [${CODE_PUSHUP_DOMAIN}](${CODE_PUSHUP_DOMAIN})`,
`${FOOTER_PREFIX} [Code PushUp](${README_LINK})`,
);

expect(console.log).toHaveBeenCalledTimes(0);
Expand All @@ -137,7 +141,7 @@ describe('persistReport', () => {

const mdReport = readFileSync(reportPath('md')).toString();
expect(mdReport).toContain(
`${FOOTER_PREFIX} [${CODE_PUSHUP_DOMAIN}](${CODE_PUSHUP_DOMAIN})`,
`${FOOTER_PREFIX} [Code PushUp](${README_LINK})`,
);

expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
Expand All @@ -156,7 +160,7 @@ describe('persistReport', () => {

const mdReport = readFileSync(reportPath('md')).toString();
expect(mdReport).toContain(
`${FOOTER_PREFIX} [${CODE_PUSHUP_DOMAIN}](${CODE_PUSHUP_DOMAIN})`,
`${FOOTER_PREFIX} [Code PushUp](${README_LINK})`,
);

expect(logs).toContain(`${FOOTER_PREFIX} ${CODE_PUSHUP_DOMAIN}`);
Expand Down
2 changes: 2 additions & 0 deletions packages/models/test/fixtures/categories.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const CATEGORIES_MAP = {
performance: {
slug: 'performance',
title: 'Performance',
description: 'Performance metrics',
docsUrl: 'https://developers.google.com/web/fundamentals/performance',
refs: [
{
type: 'group',
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { importEsmModule } from './lib/load-file';
export {
CODE_PUSHUP_DOMAIN,
FOOTER_PREFIX,
README_LINK,
calcDuration,
compareIssueSeverity,
formatBytes,
Expand Down
Loading

0 comments on commit 346596d

Please sign in to comment.