|
| 1 | +import {cp} from 'node:fs/promises'; |
| 2 | +import path from 'node:path'; |
| 3 | +import {afterAll, beforeAll, expect} from 'vitest'; |
| 4 | +import {nxTargetProject} from '@code-pushup/test-nx-utils'; |
| 5 | +import {teardownTestFolder} from '@code-pushup/test-setup'; |
| 6 | +import {E2E_ENVIRONMENTS_DIR, removeColorCodes, TEST_OUTPUT_DIR,} from '@code-pushup/test-utils'; |
| 7 | +import {executeProcess, readJsonFile} from '@code-pushup/utils'; |
| 8 | +import {getCurrentTsVersion} from "@code-pushup/typescript-plugin"; |
| 9 | + |
| 10 | +describe('PLUGIN collect report with typescript-plugin NPM package', () => { |
| 11 | + const testFileDir = path.join( |
| 12 | + E2E_ENVIRONMENTS_DIR, |
| 13 | + nxTargetProject(), |
| 14 | + TEST_OUTPUT_DIR, |
| 15 | + 'collect', |
| 16 | + ); |
| 17 | + const defaultSetupDir = path.join(testFileDir, 'default-setup'); |
| 18 | + |
| 19 | + const fixturesDir = path.join('e2e', nxTargetProject(), 'mocks/fixtures'); |
| 20 | + |
| 21 | + beforeAll(async () => { |
| 22 | + await cp(fixturesDir, testFileDir, {recursive: true}); |
| 23 | + }); |
| 24 | + |
| 25 | + afterAll(async () => { |
| 26 | + await teardownTestFolder(testFileDir); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should run plugin over CLI and creates report.json', async () => { |
| 30 | + const {code, stdout} = await executeProcess({ |
| 31 | + command: 'npx', |
| 32 | + // verbose exposes audits with perfect scores that are hidden in the default stdout |
| 33 | + args: ['@code-pushup/cli', 'collect', '--no-progress', '--verbose'], |
| 34 | + cwd: defaultSetupDir, |
| 35 | + }); |
| 36 | + |
| 37 | + expect(code).toBe(0); |
| 38 | + const cleanStdout = removeColorCodes(stdout); |
| 39 | + expect(cleanStdout).toContain('● NoImplicitAny'); |
| 40 | + |
| 41 | + await expect(readJsonFile( |
| 42 | + path.join('node_modules', '.code-pushup', 'plugin-typescript', 'default-ts-configs', await getCurrentTsVersion()), |
| 43 | + )).resolves.not.toThrow(); |
| 44 | + }); |
| 45 | +}); |
0 commit comments