Skip to content

Commit

Permalink
revert cli-e2e changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Oct 1, 2024
1 parent 5ed0731 commit 00c1b04
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.
13 changes: 6 additions & 7 deletions e2e/cli-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@code-pushup/models';
import { cleanTestFolder } from '@code-pushup/test-setup';
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';
import { EXAMPLES_REACT_TODOS_APP } from '../mocks/fixtures/constant';

describe('CLI collect', () => {
const exampleCategoryTitle = 'Code style';
Expand Down Expand Up @@ -51,13 +50,14 @@ describe('CLI collect', () => {
});

it('should run ESLint plugin and create report.json', async () => {
const { code } = await executeProcess({
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress', '--onlyPlugins=eslint'],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
expect(stderr).toBe('');

const report = await readJsonFile('tmp/e2e/react-todos-app/report.json');

Expand Down Expand Up @@ -91,7 +91,6 @@ describe('CLI collect', () => {
'--persist.outputDir=tmp/e2e',
'--onlyPlugins=coverage',
],
cwd: EXAMPLES_REACT_TODOS_APP,
});

expect(code).toBe(0);
Expand All @@ -107,7 +106,7 @@ describe('CLI collect', () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress', '--onlyPlugins=coverage'],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
Expand All @@ -123,7 +122,7 @@ describe('CLI collect', () => {
const { code, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--persist.format=md', '--no-progress'],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
Expand All @@ -140,7 +139,7 @@ describe('CLI collect', () => {
const { code, stdout, stderr } = await executeProcess({
command: 'code-pushup',
args: ['collect', '--no-progress'],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});

expect(code).toBe(0);
Expand Down
25 changes: 10 additions & 15 deletions e2e/cli-e2e/tests/compare.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,56 @@ import { simpleGit } from 'simple-git';
import type { ReportsDiff } from '@code-pushup/models';
import { cleanTestFolder } from '@code-pushup/test-setup';
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';
import { EXAMPLES_REACT_TODOS_APP } from '../mocks/fixtures/constant';

describe('CLI compare', () => {
const git = simpleGit();

beforeEach(async () => {
if (await git.diff(['--', EXAMPLES_REACT_TODOS_APP])) {
if (await git.diff(['--', 'examples/react-todos-app'])) {
throw new Error(
'Unstaged changes found in examples/react-todos-app, please stage or commit them to prevent E2E tests interfering',
);
}
await cleanTestFolder('tmp/e2e/react-todos-app');
await executeProcess({
command: 'npx',
command: 'code-pushup',
args: [
'@code-pushup/cli',
'collect',
'--persist.filename=source-report',
'--onlyPlugins=eslint',
],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});
await executeProcess({
command: 'npx',
args: ['eslint', '--fix', 'src', '--ext=js,jsx'],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});
await executeProcess({
command: 'npx',
command: 'code-pushup',
args: [
'@code-pushup/cli',
'collect',
'--persist.filename=target-report',
'--onlyPlugins=eslint',
],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});
}, 20_000);

afterEach(async () => {
await git.checkout(['--', EXAMPLES_REACT_TODOS_APP]);
await git.checkout(['--', 'examples/react-todos-app']);
await cleanTestFolder('tmp/e2e');
});

// eslint-disable-next-line vitest/no-disabled-tests
it.skip('should compare report.json files and create report-diff.json and report-diff.md', async () => {
it('should compare report.json files and create report-diff.json and report-diff.md', async () => {
await executeProcess({
command: 'npx',
command: 'code-pushup',
args: [
'@code-pushup/cli',
'compare',
'--before=../../tmp/e2e/react-todos-app/source-report.json',
'--after=../../tmp/e2e/react-todos-app/target-report.json',
],
cwd: EXAMPLES_REACT_TODOS_APP,
cwd: 'examples/react-todos-app',
});

const reportsDiff = await readJsonFile<ReportsDiff>(
Expand Down
16 changes: 6 additions & 10 deletions e2e/cli-e2e/tests/help.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { removeColorCodes } from '@code-pushup/test-utils';
import { executeProcess } from '@code-pushup/utils';
import { EXAMPLES_REACT_TODOS_APP } from '../mocks/fixtures/constant';

describe('CLI help', () => {
it('should print help with help command', async () => {
const { code, stdout, stderr } = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'help'],
cwd: EXAMPLES_REACT_TODOS_APP,
command: 'code-pushup',
args: ['help'],
});
expect(code).toBe(0);
expect(stderr).toBe('');
Expand All @@ -16,14 +14,12 @@ describe('CLI help', () => {

it('should produce the same output to stdout for both help argument and help command', async () => {
const helpArgResult = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', 'help'],
cwd: EXAMPLES_REACT_TODOS_APP,
command: 'code-pushup',
args: ['help'],
});
const helpCommandResult = await executeProcess({
command: 'npx',
args: ['@code-pushup/cli', '--help'],
cwd: EXAMPLES_REACT_TODOS_APP,
command: 'code-pushup',
args: ['--help'],
});
expect(helpArgResult.code).toBe(0);
expect(helpCommandResult.code).toBe(0);
Expand Down
5 changes: 1 addition & 4 deletions e2e/cli-e2e/tests/print-config.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { join } from 'node:path';
import { expect } from 'vitest';
import { executeProcess } from '@code-pushup/utils';
import { EXAMPLES_REACT_TODOS_APP } from '../mocks/fixtures/constant';

const extensions = ['js', 'mjs', 'ts'] as const;
export const configFilePath = (ext: (typeof extensions)[number]) =>
join(process.cwd(), `e2e/cli-e2e/mocks/fixtures/code-pushup.config.${ext}`);

describe('CLI print-config', () => {
describe('print-config', () => {
it.each(extensions)(
'should load .%s config file with correct arguments',
async ext => {
const { code, stdout } = await executeProcess({
command: 'code-pushup',
args: [
'@code-pushup/cli',
'print-config',
'--no-progress',
`--config=${configFilePath(ext)}`,
Expand All @@ -24,7 +22,6 @@ describe('CLI print-config', () => {
`--persist.filename=${ext}-report`,
'--onlyPlugins=coverage',
],
cwd: EXAMPLES_REACT_TODOS_APP,
});

expect(code).toBe(0);
Expand Down

0 comments on commit 00c1b04

Please sign in to comment.