Skip to content

Commit 7f68bfb

Browse files
committed
refactor(plugin-eslint-e2e): fix e2e test
1 parent 0e37057 commit 7f68bfb

File tree

3 files changed

+119
-3
lines changed

3 files changed

+119
-3
lines changed

e2e/plugin-eslint-e2e/mocks/fixtures/artifacts-config/code-pushup.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export default {
77
{
88
artifacts: {
99
generateArtifactsCommand:
10-
"npx eslint 'src/*.js' --format json --output-file ./code-pushup/eslint-report.json",
11-
artifactsPaths: ['./code-pushup/eslint-report.json'],
10+
'npx eslint src/*.js --format json --output-file ./.code-pushup/eslint-report.json',
11+
artifactsPaths: ['./.code-pushup/eslint-report.json'],
1212
},
1313
},
1414
),

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

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,119 @@ Custom options:
341341
],
342342
}
343343
`;
344+
345+
exports[`PLUGIN collect report with eslint-plugin NPM package > should run ESLint plugin with artifacts options and create eslint-report.json and report.json 1`] = `
346+
{
347+
"packageName": "@code-pushup/core",
348+
"plugins": [
349+
{
350+
"audits": [
351+
{
352+
"description": "ESLint rule **eqeqeq**.",
353+
"details": {
354+
"issues": [
355+
{
356+
"message": "Expected '===' and instead saw '=='.",
357+
"severity": "error",
358+
"source": {
359+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
360+
"position": {
361+
"endColumn": 15,
362+
"endLine": 6,
363+
"startColumn": 13,
364+
"startLine": 6,
365+
},
366+
},
367+
},
368+
],
369+
},
370+
"displayValue": "1 error",
371+
"docsUrl": "https://eslint.org/docs/latest/rules/eqeqeq",
372+
"score": 0,
373+
"slug": "eqeqeq",
374+
"title": "Require the use of \`===\` and \`!==\`",
375+
"value": 1,
376+
},
377+
{
378+
"description": "ESLint rule **max-lines**.
379+
380+
Custom options:
381+
382+
\`\`\`json
383+
100
384+
\`\`\`",
385+
"details": {
386+
"issues": [],
387+
},
388+
"displayValue": "passed",
389+
"docsUrl": "https://eslint.org/docs/latest/rules/max-lines",
390+
"score": 1,
391+
"slug": "max-lines-71b54366cb01f77b",
392+
"title": "Enforce a maximum number of lines per file",
393+
"value": 0,
394+
},
395+
{
396+
"description": "ESLint rule **no-unused-vars**.",
397+
"details": {
398+
"issues": [
399+
{
400+
"message": "'unusedFn' is defined but never used.",
401+
"severity": "warning",
402+
"source": {
403+
"file": "tmp/e2e/plugin-eslint-e2e/__test__/artifacts-config/src/index.js",
404+
"position": {
405+
"endColumn": 18,
406+
"endLine": 1,
407+
"startColumn": 10,
408+
"startLine": 1,
409+
},
410+
},
411+
},
412+
],
413+
},
414+
"displayValue": "1 warning",
415+
"docsUrl": "https://eslint.org/docs/latest/rules/no-unused-vars",
416+
"score": 0,
417+
"slug": "no-unused-vars",
418+
"title": "Disallow unused variables",
419+
"value": 1,
420+
},
421+
],
422+
"description": "Official Code PushUp ESLint plugin",
423+
"docsUrl": "https://www.npmjs.com/package/@code-pushup/eslint-plugin",
424+
"groups": [
425+
{
426+
"description": "Code that either will cause an error or may cause confusing behavior. Developers should consider this a high priority to resolve.",
427+
"refs": [
428+
{
429+
"slug": "no-unused-vars",
430+
"weight": 1,
431+
},
432+
],
433+
"slug": "problems",
434+
"title": "Problems",
435+
},
436+
{
437+
"description": "Something that could be done in a better way but no errors will occur if the code isn't changed.",
438+
"refs": [
439+
{
440+
"slug": "eqeqeq",
441+
"weight": 1,
442+
},
443+
{
444+
"slug": "max-lines-71b54366cb01f77b",
445+
"weight": 1,
446+
},
447+
],
448+
"slug": "suggestions",
449+
"title": "Suggestions",
450+
},
451+
],
452+
"icon": "eslint",
453+
"packageName": "@code-pushup/eslint-plugin",
454+
"slug": "eslint",
455+
"title": "ESLint",
456+
},
457+
],
458+
}
459+
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('PLUGIN collect report with eslint-plugin NPM package', () => {
9292
expect(omitVariableReportData(report as Report)).toMatchSnapshot();
9393
});
9494

95-
it('should run ESLint plugin with artifacts options', async () => {
95+
it('should run ESLint plugin with artifacts options and create eslint-report.json and report.json', async () => {
9696
const { code } = await executeProcess({
9797
command: 'npx',
9898
args: ['@code-pushup/cli', 'collect', '--no-progress'],

0 commit comments

Comments
 (0)