Skip to content
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
2 changes: 0 additions & 2 deletions .nxignore

This file was deleted.

4 changes: 4 additions & 0 deletions e2e/ci-e2e/mocks/fixtures/npm-workspaces/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"private": true,
"workspaces": ["packages/*"]
}
6 changes: 0 additions & 6 deletions e2e/ci-e2e/mocks/fixtures/npm-workspaces/package.json

This file was deleted.

2 changes: 2 additions & 0 deletions e2e/ci-e2e/mocks/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
initGitRepo,
restoreNxIgnoredFiles,
simulateGitFetch,
teardownTestFolder,
} from '@code-pushup/test-utils';
Expand All @@ -28,6 +29,7 @@ export async function setupTestRepo(folder: string) {
);

await cp(fixturesDir, baseDir, { recursive: true });
await restoreNxIgnoredFiles(baseDir);

const git = await initGitRepo(simpleGit, { baseDir });
await simulateGitFetch(git);
Expand Down
2 changes: 2 additions & 0 deletions e2e/cli-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import {
Expand Down Expand Up @@ -36,6 +37,7 @@ describe('CLI collect', () => {

beforeAll(async () => {
await cp(fixtureDummyDir, dummyDir, { recursive: true });
await restoreNxIgnoredFiles(dummyDir);
});

afterAll(async () => {
Expand Down
2 changes: 2 additions & 0 deletions e2e/cli-e2e/tests/compare.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';
Expand All @@ -30,6 +31,7 @@ describe('CLI compare', () => {

beforeAll(async () => {
await cp(fixtureDummyDir, existingDir, { recursive: true });
await restoreNxIgnoredFiles(existingDir);
});

afterAll(async () => {
Expand Down
2 changes: 2 additions & 0 deletions e2e/plugin-coverage-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TEST_OUTPUT_DIR,
initGitRepo,
omitVariableReportData,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand All @@ -24,6 +25,7 @@ describe('PLUGIN collect report with coverage-plugin NPM package', () => {

beforeAll(async () => {
await cp(fixtureDir, testFileDir, { recursive: true });
await restoreNxIgnoredFiles(testFileDir);
await initGitRepo(simpleGit, { baseDir: basicDir });
await initGitRepo(simpleGit, { baseDir: existingDir });
});
Expand Down
4 changes: 4 additions & 0 deletions e2e/plugin-eslint-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
omitVariableReportData,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand Down Expand Up @@ -39,10 +40,13 @@ describe('PLUGIN collect report with eslint-plugin NPM package', () => {

beforeAll(async () => {
await cp(fixturesFlatConfigDir, flatConfigDir, { recursive: true });
await restoreNxIgnoredFiles(flatConfigDir);
await cp(fixturesLegacyConfigDir, legacyConfigDir, { recursive: true });
await restoreNxIgnoredFiles(legacyConfigDir);
await cp(fixturesArtifactsConfigDir, artifactsConfigDir, {
recursive: true,
});
await restoreNxIgnoredFiles(artifactsConfigDir);
});

afterAll(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { nxTargetProject } from '@code-pushup/test-nx-utils';
import {
E2E_ENVIRONMENTS_DIR,
TEST_OUTPUT_DIR,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand All @@ -32,6 +33,7 @@ describe('plugin-js-packages', () => {

beforeAll(async () => {
await cp(fixturesNPMDir, npmRepoDir, { recursive: true });
await restoreNxIgnoredFiles(npmRepoDir);
});

afterAll(async () => {
Expand Down
3 changes: 3 additions & 0 deletions e2e/plugin-jsdocs-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TEST_OUTPUT_DIR,
initGitRepo,
omitVariableReportData,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand Down Expand Up @@ -36,6 +37,8 @@ describe('PLUGIN collect report with jsdocs-plugin NPM package', () => {
beforeAll(async () => {
await cp(fixturesAngularDir, angularDir, { recursive: true });
await cp(fixturesReactDir, reactDir, { recursive: true });
await restoreNxIgnoredFiles(angularDir);
await restoreNxIgnoredFiles(reactDir);
await initGitRepo(simpleGit, { baseDir: angularDir });
await initGitRepo(simpleGit, { baseDir: reactDir });
});
Expand Down
2 changes: 2 additions & 0 deletions e2e/plugin-lighthouse-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TEST_OUTPUT_DIR,
omitVariableReportData,
removeColorCodes,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand All @@ -25,6 +26,7 @@ describe('PLUGIN collect report with lighthouse-plugin NPM package', () => {

beforeAll(async () => {
await cp(fixturesDir, testFileDir, { recursive: true });
await restoreNxIgnoredFiles(testFileDir);
});

afterAll(async () => {
Expand Down
2 changes: 2 additions & 0 deletions e2e/plugin-typescript-e2e/tests/collect.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
omitVariableReportData,
osAgnosticAuditOutputs,
osAgnosticPath,
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { executeProcess, readJsonFile } from '@code-pushup/utils';
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => {

beforeAll(async () => {
await cp(fixturesDir, envRoot, { recursive: true });
await restoreNxIgnoredFiles(envRoot);
});

afterAll(async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/ci/mocks/fixtures/monorepos/npm/_package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"private": true,
"workspaces": ["packages/*"]
}
6 changes: 0 additions & 6 deletions packages/ci/mocks/fixtures/monorepos/npm/package.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packageManager": "yarn@1.22.19",
"private": true,
"workspaces": [
"packages/*"
]
"workspaces": ["packages/*"]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packageManager": "yarn@4.5.0",
"private": true,
"workspaces": [
"packages/*"
]
"workspaces": ["packages/*"]
}
3 changes: 3 additions & 0 deletions packages/ci/src/lib/run.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import {
cleanTestFolder,
initGitRepo,
restoreNxIgnoredFiles,
simulateGitFetch,
teardownTestFolder,
} from '@code-pushup/test-utils';
Expand Down Expand Up @@ -624,6 +625,7 @@ describe('runInCI', () => {
beforeEach(async () => {
const monorepoDir = path.join(fixturesDir, 'monorepos', tool);
await cp(monorepoDir, workDir, { recursive: true });
await restoreNxIgnoredFiles(workDir);
await git.add('.');
await git.commit(`Create packages in ${tool} monorepo`);
setup?.();
Expand Down Expand Up @@ -1137,6 +1139,7 @@ describe('runInCI', () => {
beforeEach(async () => {
const monorepoDir = path.join(fixturesDir, 'monorepos', 'custom');
await cp(monorepoDir, workDir, { recursive: true });
await restoreNxIgnoredFiles(workDir);
await git.add('.');
await git.commit('Create projects in monorepo');
});
Expand Down
32 changes: 25 additions & 7 deletions packages/plugin-eslint/src/lib/eslint-plugin.int.test.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
import ansis from 'ansis';
import { cp } from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import type { MockInstance } from 'vitest';
import type { Audit } from '@code-pushup/models';
import {
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import { eslintPlugin } from './eslint-plugin.js';

describe('eslintPlugin', () => {
const thisDir = fileURLToPath(path.dirname(import.meta.url));

const fixturesDir = path.join(thisDir, '..', '..', 'mocks', 'fixtures');

const tmpDir = path.join(process.cwd(), 'tmp', 'int', 'plugin-eslint');
let cwdSpy: MockInstance<[], string>;
let platformSpy: MockInstance<[], NodeJS.Platform>;

beforeAll(() => {
beforeAll(async () => {
await cp(
path.join(fixturesDir, 'nx-monorepo'),
path.join(tmpDir, 'nx-monorepo'),
{ recursive: true },
);
await restoreNxIgnoredFiles(path.join(tmpDir, 'nx-monorepo'));
await cp(
path.join(fixturesDir, 'todos-app'),
path.join(tmpDir, 'todos-app'),
{ recursive: true },
);
await restoreNxIgnoredFiles(path.join(tmpDir, 'todos-app'));
cwdSpy = vi.spyOn(process, 'cwd');
// Linux produces extra quotation marks for globs
platformSpy = vi.spyOn(os, 'platform').mockReturnValue('linux');
});

afterAll(() => {
afterAll(async () => {
cwdSpy.mockRestore();
platformSpy.mockRestore();
await teardownTestFolder(tmpDir);
});

it('should initialize ESLint plugin for React application', async () => {
cwdSpy.mockReturnValue(path.join(fixturesDir, 'todos-app'));
cwdSpy.mockReturnValue(path.join(tmpDir, 'todos-app'));

const plugin = await eslintPlugin({
eslintrc: 'eslint.config.js',
Expand All @@ -40,7 +58,7 @@ describe('eslintPlugin', () => {
});

it('should initialize ESLint plugin for Nx project', async () => {
cwdSpy.mockReturnValue(path.join(fixturesDir, 'nx-monorepo'));
cwdSpy.mockReturnValue(path.join(tmpDir, 'nx-monorepo'));
const plugin = await eslintPlugin({
eslintrc: './packages/nx-plugin/eslint.config.js',
patterns: ['packages/nx-plugin/**/*.ts', 'packages/nx-plugin/**/*.json'],
Expand All @@ -62,7 +80,7 @@ describe('eslintPlugin', () => {
});

it('should initialize with plugin options for custom groups', async () => {
cwdSpy.mockReturnValue(path.join(fixturesDir, 'nx-monorepo'));
cwdSpy.mockReturnValue(path.join(tmpDir, 'nx-monorepo'));
const plugin = await eslintPlugin(
{
eslintrc: './packages/nx-plugin/eslint.config.js',
Expand Down Expand Up @@ -140,7 +158,7 @@ describe('eslintPlugin', () => {
});

it('should initialize with artifact options', async () => {
cwdSpy.mockReturnValue(path.join(fixturesDir, 'todos-app'));
cwdSpy.mockReturnValue(path.join(tmpDir, 'todos-app'));
const plugin = await eslintPlugin(
{
eslintrc: 'eslint.config.js',
Expand Down
26 changes: 21 additions & 5 deletions packages/plugin-eslint/src/lib/meta/rules.int.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { cp } from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import type { MockInstance } from 'vitest';
import {
restoreNxIgnoredFiles,
teardownTestFolder,
} from '@code-pushup/test-utils';
import type { ESLintTarget } from '../config.js';
import type { RuleData } from './parse.js';
import { listRules } from './rules.js';
Expand All @@ -14,25 +20,31 @@ describe('listRules', () => {
'mocks',
'fixtures',
);
const tmpDir = path.join(process.cwd(), 'tmp', 'int', 'plugin-eslint');

let cwdSpy: MockInstance<[], string>;

beforeAll(() => {
cwdSpy = vi.spyOn(process, 'cwd');
});

afterAll(() => {
afterAll(async () => {
cwdSpy.mockRestore();
await teardownTestFolder(tmpDir);
});

describe('React app', () => {
const appRootDir = path.join(fixturesDir, 'todos-app');
const appRootDir = path.join(tmpDir, 'todos-app');
const eslintrc = path.join(appRootDir, 'eslint.config.js');

const patterns = ['src/**/*.js', 'src/**/*.jsx'];
const targets: ESLintTarget[] = [{ eslintrc, patterns }];

beforeAll(() => {
beforeAll(async () => {
await cp(path.join(fixturesDir, 'todos-app'), appRootDir, {
recursive: true,
});
await restoreNxIgnoredFiles(appRootDir);
cwdSpy.mockReturnValue(appRootDir);
});

Expand Down Expand Up @@ -89,13 +101,17 @@ describe('listRules', () => {
});

describe('Nx monorepo project', () => {
const nxRootDir = path.join(fixturesDir, 'nx-monorepo');
const nxRootDir = path.join(tmpDir, 'nx-monorepo');
const eslintrc = path.join(nxRootDir, 'packages/utils/eslint.config.js');

const patterns = ['packages/utils/**/*.ts', 'packages/utils/**/*.json'];
const targets: ESLintTarget[] = [{ eslintrc, patterns }];

beforeAll(() => {
beforeAll(async () => {
await cp(path.join(fixturesDir, 'nx-monorepo'), nxRootDir, {
recursive: true,
});
await restoreNxIgnoredFiles(nxRootDir);
cwdSpy.mockReturnValue(nxRootDir);
});

Expand Down
Loading
Loading