Skip to content

Commit fa90bcd

Browse files
committed
refactor e2e env setup
1 parent 385f0e3 commit fa90bcd

File tree

7 files changed

+22
-29
lines changed

7 files changed

+22
-29
lines changed

e2e/plugin-eslint-e2e/mocks/fixtures/.eslintrc.json renamed to e2e/plugin-eslint-e2e/mocks/fixtures/old-version/.eslintrc.json

File renamed without changes.

e2e/plugin-eslint-e2e/mocks/fixtures/code-pushup.config.ts renamed to e2e/plugin-eslint-e2e/mocks/fixtures/old-version/code-pushup.config.ts

File renamed without changes.

e2e/plugin-eslint-e2e/mocks/fixtures/src/index.js renamed to e2e/plugin-eslint-e2e/mocks/fixtures/old-version/src/index.js

File renamed without changes.

e2e/plugin-eslint-e2e/project.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@
1111
"lintFilePatterns": ["e2e/plugin-eslint-e2e/**/*.ts"]
1212
}
1313
},
14-
"nxv-e2e": {
15-
"options": {
16-
"environmentRoot": "tmp/plugin-eslint-e2e/__test-env__"
17-
}
18-
},
19-
"nxv-env-setup": {
20-
"options": {
21-
"environmentRoot": "tmp/plugin-eslint-e2e/__test-env__"
22-
}
23-
},
2414
"e2e": {
2515
"executor": "@nx/vite:test",
2616
"options": {

e2e/plugin-eslint-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ exports[`collect report with eslint-plugin NPM package > should run ESLint plugi
4242
"message": "'unusedFn' is defined but never used.",
4343
"severity": "error",
4444
"source": {
45-
"file": "tmp/plugin-eslint-e2e/__test-env__/src/index.js",
45+
"file": "tmp/e2e/plugin-eslint-e2e/old-version/src/index.js",
4646
"position": {
4747
"endColumn": 18,
4848
"endLine": 1,
@@ -68,7 +68,7 @@ exports[`collect report with eslint-plugin NPM package > should run ESLint plugi
6868
"message": "Unexpected console statement.",
6969
"severity": "warning",
7070
"source": {
71-
"file": "tmp/plugin-eslint-e2e/__test-env__/src/index.js",
71+
"file": "tmp/e2e/plugin-eslint-e2e/old-version/src/index.js",
7272
"position": {
7373
"endColumn": 14,
7474
"endLine": 6,

e2e/plugin-eslint-e2e/tests/collect.e2e.test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
1-
import { cp, rm } from 'node:fs/promises';
1+
import { cp } from 'node:fs/promises';
22
import { join } from 'node:path';
3-
import { afterEach } from 'vitest';
3+
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
44
import { type Report, reportSchema } from '@code-pushup/models';
55
import { teardownTestFolder } from '@code-pushup/test-setup';
66
import { omitVariableReportData } from '@code-pushup/test-utils';
77
import { executeProcess, readJsonFile } from '@code-pushup/utils';
88

99
describe('collect report with eslint-plugin NPM package', () => {
10-
const fixturesDir = join('e2e', 'plugin-eslint-e2e', 'mocks', 'fixtures');
11-
const envRoot = join('tmp', 'plugin-eslint-e2e', '__test-env__');
12-
const outputDir = join(envRoot, '.code-pushup');
10+
const fixturesOldVersionDir = join(
11+
'e2e',
12+
'plugin-eslint-e2e',
13+
'mocks',
14+
'fixtures',
15+
'old-version',
16+
);
17+
const envRoot = join('tmp', 'e2e', 'plugin-eslint-e2e');
18+
const oldVersionDir = join(envRoot, 'old-version');
19+
const oldVersionOutputDir = join(oldVersionDir, '.code-pushup');
1320

1421
beforeAll(async () => {
15-
await cp(fixturesDir, envRoot, { recursive: true });
22+
await cp(fixturesOldVersionDir, oldVersionDir, { recursive: true });
1623
});
1724

1825
afterAll(async () => {
19-
await rm(envRoot, { recursive: true, force: true });
26+
await teardownTestFolder(oldVersionDir);
2027
});
2128

2229
afterEach(async () => {
23-
await teardownTestFolder(outputDir);
30+
await teardownTestFolder(oldVersionOutputDir);
2431
});
2532

2633
it('should run ESLint plugin and create report.json', async () => {
2734
const { code, stderr } = await executeProcess({
2835
command: 'npx',
29-
args: [
30-
'@code-pushup/cli',
31-
'collect',
32-
'--no-progress',
33-
'--onlyPlugins=eslint',
34-
],
35-
cwd: envRoot,
36+
args: ['@code-pushup/cli', 'collect', '--no-progress'],
37+
cwd: oldVersionDir,
3638
});
3739

3840
expect(code).toBe(0);
3941
expect(stderr).toBe('');
4042

41-
const report = await readJsonFile(join(outputDir, 'report.json'));
43+
const report = await readJsonFile(join(oldVersionOutputDir, 'report.json'));
4244

4345
expect(() => reportSchema.parse(report)).not.toThrow();
4446
expect(omitVariableReportData(report as Report)).toMatchSnapshot();

nx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
"dependsOn": ["^build"]
3030
},
3131
"nxv-e2e": {
32-
"executor": "@push-based/nx-verdaccio:env-setup"
32+
"executor": "@push-based/nx-verdaccio:env-teardown"
3333
},
3434
"nxv-env-setup": {
35+
"cache": true,
3536
"executor": "@push-based/nx-verdaccio:env-setup"
3637
},
3738
"@nx/vite:test": {

0 commit comments

Comments
 (0)