@@ -7,10 +7,47 @@ import {
77 E2E_ENVIRONMENTS_DIR ,
88 TEST_OUTPUT_DIR ,
99 omitVariableReportData ,
10+ osAgnosticPath ,
1011 teardownTestFolder ,
1112} from '@code-pushup/test-utils' ;
1213import { executeProcess , readJsonFile } from '@code-pushup/utils' ;
1314
15+ function sanitizeReportPaths ( report : Report ) : Report {
16+ return {
17+ ...report ,
18+ plugins : report . plugins . map ( plugin => ( {
19+ ...plugin ,
20+ audits : plugin . audits . map ( audit => ( {
21+ ...audit ,
22+ ...( audit . details && {
23+ details : {
24+ ...audit . details ,
25+ issues : audit . details . issues ?. map ( issue => ( {
26+ ...issue ,
27+ ...( issue . source && {
28+ source : {
29+ ...issue . source ,
30+ file : osAgnosticPath ( issue . source . file ) ,
31+ } ,
32+ } ) ,
33+ message : issue . message . replace (
34+ / [ ' " ] ( [ ^ ' " ] * [ \/ \\ ] [ ^ ' " ] * ) [ ' " ] / g,
35+ ( match , filePath ) => {
36+ try {
37+ return `'${ osAgnosticPath ( filePath ) } '` ;
38+ } catch {
39+ return match ;
40+ }
41+ } ,
42+ ) ,
43+ } ) ) ,
44+ } ,
45+ } ) ,
46+ } ) ) ,
47+ } ) ) ,
48+ } ;
49+ }
50+
1451describe ( 'PLUGIN collect report with typescript-plugin NPM package' , ( ) => {
1552 const envRoot = path . join ( E2E_ENVIRONMENTS_DIR , nxTargetProject ( ) ) ;
1653 const distRoot = path . join ( envRoot , TEST_OUTPUT_DIR ) ;
@@ -57,6 +94,9 @@ describe('PLUGIN collect report with typescript-plugin NPM package', () => {
5794 path . join ( envRoot , outputDir , 'report.json' ) ,
5895 ) ;
5996 expect ( ( ) => reportSchema . parse ( reportJson ) ) . not . toThrow ( ) ;
60- expect ( omitVariableReportData ( reportJson ) ) . toMatchSnapshot ( ) ;
97+
98+ expect (
99+ omitVariableReportData ( sanitizeReportPaths ( reportJson ) ) ,
100+ ) . toMatchSnapshot ( ) ;
61101 } ) ;
62102} ) ;
0 commit comments