Skip to content

Commit 5ed0731

Browse files
committed
Merge branch 'e2e-separate-lighthouse-plugin' into reduce-e2e-targets
# Conflicts: # e2e/cli-e2e/tests/collect.e2e.test.ts
2 parents 6e54084 + 7d13e6c commit 5ed0731

24 files changed

+535
-234
lines changed

e2e/cli-e2e/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"cli",
2626
"cli",
2727
"plugin-eslint",
28-
"plugin-lighthouse",
2928
"plugin-coverage",
3029
"plugin-js-packages",
3130
"react-todos-app"

e2e/cli-e2e/tests/__snapshots__/collect.e2e.test.ts.snap

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,133 +1419,3 @@ exports[`CLI collect > should run ESLint plugin and create report.json 1`] = `
14191419
],
14201420
}
14211421
`;
1422-
1423-
exports[`CLI collect > should run Lighthouse plugin that runs lighthouse CLI and creates report.json 1`] = `
1424-
{
1425-
"categories": [
1426-
{
1427-
"refs": [
1428-
{
1429-
"plugin": "lighthouse",
1430-
"slug": "performance",
1431-
"type": "group",
1432-
"weight": 1,
1433-
},
1434-
],
1435-
"slug": "performance",
1436-
"title": "Performance",
1437-
},
1438-
{
1439-
"refs": [
1440-
{
1441-
"plugin": "lighthouse",
1442-
"slug": "accessibility",
1443-
"type": "group",
1444-
"weight": 1,
1445-
},
1446-
],
1447-
"slug": "a11y",
1448-
"title": "Accessibility",
1449-
},
1450-
{
1451-
"refs": [
1452-
{
1453-
"plugin": "lighthouse",
1454-
"slug": "best-practices",
1455-
"type": "group",
1456-
"weight": 1,
1457-
},
1458-
],
1459-
"slug": "best-practices",
1460-
"title": "Best Practices",
1461-
},
1462-
{
1463-
"refs": [
1464-
{
1465-
"plugin": "lighthouse",
1466-
"slug": "seo",
1467-
"type": "group",
1468-
"weight": 1,
1469-
},
1470-
],
1471-
"slug": "seo",
1472-
"title": "SEO",
1473-
},
1474-
],
1475-
"packageName": "@code-pushup/core",
1476-
"plugins": [
1477-
{
1478-
"audits": [
1479-
{
1480-
"description": "Largest Contentful Paint marks the time at which the largest text or image is painted. [Learn more about the Largest Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint/)",
1481-
"slug": "largest-contentful-paint",
1482-
"title": "Largest Contentful Paint",
1483-
},
1484-
{
1485-
"description": "Deprecated APIs will eventually be removed from the browser. [Learn more about deprecated APIs](https://developer.chrome.com/docs/lighthouse/best-practices/deprecations/).",
1486-
"slug": "deprecations",
1487-
"title": "Avoids deprecated APIs",
1488-
},
1489-
{
1490-
"description": "Each ARIA \`role\` supports a specific subset of \`aria-*\` attributes. Mismatching these invalidates the \`aria-*\` attributes. [Learn how to match ARIA attributes to their roles](https://dequeuniversity.com/rules/axe/4.9/aria-allowed-attr).",
1491-
"slug": "aria-allowed-attr",
1492-
"title": "\`[aria-*]\` attributes match their roles",
1493-
},
1494-
{
1495-
"description": "hreflang links tell search engines what version of a page they should list in search results for a given language or region. [Learn more about \`hreflang\`](https://developer.chrome.com/docs/lighthouse/seo/hreflang/).",
1496-
"slug": "hreflang",
1497-
"title": "Document has a valid \`hreflang\`",
1498-
},
1499-
],
1500-
"groups": [
1501-
{
1502-
"refs": [
1503-
{
1504-
"slug": "largest-contentful-paint",
1505-
"weight": 25,
1506-
},
1507-
],
1508-
"slug": "performance",
1509-
"title": "Performance",
1510-
},
1511-
{
1512-
"description": "These checks highlight opportunities to [improve the accessibility of your web app](https://developer.chrome.com/docs/lighthouse/accessibility/). Automatic detection can only detect a subset of issues and does not guarantee the accessibility of your web app, so [manual testing](https://web.dev/articles/how-to-review) is also encouraged.",
1513-
"refs": [
1514-
{
1515-
"slug": "aria-allowed-attr",
1516-
"weight": 10,
1517-
},
1518-
],
1519-
"slug": "accessibility",
1520-
"title": "Accessibility",
1521-
},
1522-
{
1523-
"refs": [
1524-
{
1525-
"slug": "deprecations",
1526-
"weight": 5,
1527-
},
1528-
],
1529-
"slug": "best-practices",
1530-
"title": "Best Practices",
1531-
},
1532-
{
1533-
"description": "These checks ensure that your page is following basic search engine optimization advice. There are many additional factors Lighthouse does not score here that may affect your search ranking, including performance on [Core Web Vitals](https://web.dev/explore/vitals). [Learn more about Google Search Essentials](https://support.google.com/webmasters/answer/35769).",
1534-
"refs": [
1535-
{
1536-
"slug": "hreflang",
1537-
"weight": 1,
1538-
},
1539-
],
1540-
"slug": "seo",
1541-
"title": "SEO",
1542-
},
1543-
],
1544-
"icon": "lighthouse",
1545-
"packageName": "@code-pushup/lighthouse-plugin",
1546-
"slug": "lighthouse",
1547-
"title": "Lighthouse",
1548-
},
1549-
],
1550-
}
1551-
`;

e2e/cli-e2e/tests/collect.e2e.test.ts

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,8 @@ describe('CLI collect', () => {
5252

5353
it('should run ESLint plugin and create report.json', async () => {
5454
const { code } = await executeProcess({
55-
command: 'npx',
56-
args: [
57-
'@code-pushup/cli',
58-
'collect',
59-
'--no-progress',
60-
'--onlyPlugins=eslint',
61-
],
55+
command: 'code-pushup',
56+
args: ['collect', '--no-progress', '--onlyPlugins=eslint'],
6257
cwd: EXAMPLES_REACT_TODOS_APP,
6358
});
6459

@@ -88,9 +83,8 @@ describe('CLI collect', () => {
8883
);
8984

9085
const { code, stderr } = await executeProcess({
91-
command: 'npx',
86+
command: 'code-pushup',
9287
args: [
93-
'@code-pushup/cli',
9488
'collect',
9589
'--no-progress',
9690
`--config=${configPath}`,
@@ -111,13 +105,8 @@ describe('CLI collect', () => {
111105

112106
it('should run Code coverage plugin that runs coverage tool and creates report.json', async () => {
113107
const { code, stderr } = await executeProcess({
114-
command: 'npx',
115-
args: [
116-
'@code-pushup/cli',
117-
'collect',
118-
'--no-progress',
119-
'--onlyPlugins=coverage',
120-
],
108+
command: 'code-pushup',
109+
args: ['collect', '--no-progress', '--onlyPlugins=coverage'],
121110
cwd: EXAMPLES_REACT_TODOS_APP,
122111
});
123112

@@ -130,35 +119,10 @@ describe('CLI collect', () => {
130119
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
131120
});
132121

133-
it('should run Lighthouse plugin that runs lighthouse CLI and creates report.json', async () => {
134-
const { code, stderr } = await executeProcess({
135-
command: 'npx',
136-
args: [
137-
'@code-pushup/cli',
138-
'collect',
139-
'--no-progress',
140-
'--onlyPlugins=lighthouse',
141-
],
142-
cwd: EXAMPLES_REACT_TODOS_APP,
143-
});
144-
145-
expect(code).toBe(0);
146-
expect(stderr).toBe('');
147-
148-
const report = await readJsonFile('tmp/e2e/react-todos-app/report.json');
149-
expect(() => reportSchema.parse(report)).not.toThrow();
150-
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
151-
});
152-
153122
it('should create report.md', async () => {
154123
const { code, stderr } = await executeProcess({
155-
command: 'npx',
156-
args: [
157-
'@code-pushup/cli',
158-
'collect',
159-
'--persist.format=md',
160-
'--no-progress',
161-
],
124+
command: 'code-pushup',
125+
args: ['collect', '--persist.format=md', '--no-progress'],
162126
cwd: EXAMPLES_REACT_TODOS_APP,
163127
});
164128

@@ -174,8 +138,8 @@ describe('CLI collect', () => {
174138

175139
it('should print report summary to stdout', async () => {
176140
const { code, stdout, stderr } = await executeProcess({
177-
command: 'npx',
178-
args: ['@code-pushup/cli', 'collect', '--no-progress'],
141+
command: 'code-pushup',
142+
args: ['collect', '--no-progress'],
179143
cwd: EXAMPLES_REACT_TODOS_APP,
180144
});
181145

e2e/cli-e2e/vite.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineConfig({
66
cacheDir: '../../node_modules/.vite/cli-e2e',
77
test: {
88
reporters: ['basic'],
9-
testTimeout: 140_000,
9+
testTimeout: 120_000,
1010
globals: true,
1111
alias: tsconfigPathAliases(),
1212
pool: 'threads',

e2e/create-cli-e2e/tests/init.e2e.test.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { join, relative } from 'node:path';
1+
import { dirname, join, relative } from 'node:path';
22
import { afterEach, expect } from 'vitest';
33
import { teardownTestFolder } from '@code-pushup/test-setup';
4-
import { removeColorCodes } from '@code-pushup/test-utils';
4+
import { createNpmWorkspace, removeColorCodes } from '@code-pushup/test-utils';
55
import { executeProcess, readJsonFile, readTextFile } from '@code-pushup/utils';
6-
import { createNpmWorkspace } from '../mocks/create-npm-workshpace';
76

87
describe('create-cli-inti', () => {
98
const workspaceRoot = 'tmp/e2e/create-cli-e2e';
@@ -19,7 +18,12 @@ describe('create-cli-inti', () => {
1918
await createNpmWorkspace(cwd);
2019
const { code, stdout } = await executeProcess({
2120
command: 'npm',
22-
args: ['exec', '@code-pushup/create-cli', `--userconfig=${userconfig}`],
21+
args: [
22+
'exec',
23+
'@code-pushup/create-cli',
24+
`--userconfig=${userconfig}`,
25+
`--prefix=${dirname(userconfig)}`,
26+
],
2327
cwd,
2428
});
2529

@@ -48,16 +52,20 @@ describe('create-cli-inti', () => {
4852
);
4953
});
5054

51-
// eslint-disable-next-line vitest/no-disabled-tests
52-
it.skip('should execute package correctly over npm init', async () => {
55+
it('should execute package correctly over npm init', async () => {
5356
const cwd = join(baseDir, 'npm-init');
5457
const userconfig = relative(cwd, join(workspaceRoot, '.npmrc'));
5558

5659
await createNpmWorkspace(cwd);
5760

5861
const { code, stdout } = await executeProcess({
5962
command: 'npm',
60-
args: ['init', '@code-pushup/cli', `--userconfig=${userconfig}`],
63+
args: [
64+
'init',
65+
'@code-pushup/cli',
66+
`--userconfig=${userconfig}`,
67+
`--prefix=${dirname(userconfig)}`,
68+
],
6169
cwd,
6270
});
6371

@@ -94,7 +102,12 @@ describe('create-cli-inti', () => {
94102

95103
await executeProcess({
96104
command: 'npm',
97-
args: ['init', '@code-pushup/cli', `--userconfig=${userconfig}`],
105+
args: [
106+
'init',
107+
'@code-pushup/cli',
108+
`--userconfig=${userconfig}`,
109+
`--prefix=${dirname(userconfig)}`,
110+
],
98111
cwd,
99112
});
100113

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*", "code-pushup.config*.ts"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx"],
7+
"parserOptions": {
8+
"project": ["e2e/plugin-lighthouse-e2e/tsconfig.*?.json"]
9+
}
10+
}
11+
]
12+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { DEFAULT_FLAGS } from 'chrome-launcher/dist/flags.js';
2+
import lighthousePlugin, {
3+
lighthouseGroupRef,
4+
} from '@code-pushup/lighthouse-plugin';
5+
import type { CoreConfig } from '@code-pushup/models';
6+
7+
export default {
8+
plugins: [
9+
await lighthousePlugin('https://codepushup.dev/', {
10+
// A reduced set of tests to reduce e2e tets time
11+
onlyAudits: [
12+
// performance category
13+
`largest-contentful-paint`,
14+
// a11y category
15+
`aria-allowed-attr`,
16+
// best-practices category
17+
`deprecations`,
18+
// seo category
19+
`hreflang`,
20+
],
21+
chromeFlags: DEFAULT_FLAGS.concat([`--headless`, `--verbose`]),
22+
}),
23+
],
24+
categories: [
25+
{
26+
slug: 'performance',
27+
title: 'Performance',
28+
refs: [lighthouseGroupRef('performance')],
29+
},
30+
{
31+
slug: 'a11y',
32+
title: 'Accessibility',
33+
refs: [lighthouseGroupRef('accessibility')],
34+
},
35+
{
36+
slug: 'best-practices',
37+
title: 'Best Practices',
38+
refs: [lighthouseGroupRef('best-practices')],
39+
},
40+
{
41+
slug: 'seo',
42+
title: 'SEO',
43+
refs: [lighthouseGroupRef('seo')],
44+
},
45+
],
46+
} satisfies CoreConfig;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "plugin-lighthouse-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "e2e/plugin-lighthouse-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"lint": {
8+
"executor": "@nx/linter:eslint",
9+
"outputs": ["{options.outputFile}"],
10+
"options": {
11+
"lintFilePatterns": ["e2e/plugin-lighthouse-e2e/**/*.ts"]
12+
}
13+
},
14+
"e2e": {
15+
"executor": "@nx/vite:test",
16+
"options": {
17+
"configFile": "e2e/plugin-lighthouse-e2e/vite.config.e2e.ts"
18+
}
19+
}
20+
},
21+
"implicitDependencies": [
22+
"models",
23+
"utils",
24+
"core",
25+
"cli",
26+
"plugin-lighthouse"
27+
],
28+
"tags": ["scope:plugin", "type:e2e"]
29+
}

0 commit comments

Comments
 (0)