1
1
import { readFile , rename , writeFile } from 'node:fs/promises' ;
2
- import { join } from 'node:path' ;
2
+ import path from 'node:path' ;
3
3
import type { SimpleGit } from 'simple-git' ;
4
4
import { afterEach } from 'vitest' ;
5
5
import {
@@ -54,16 +54,21 @@ describe('CI - monorepo mode (Nx)', () => {
54
54
name : 'api' ,
55
55
files : {
56
56
report : {
57
- json : join ( repo . baseDir , 'apps/api/.code-pushup/report.json' ) ,
58
- md : join ( repo . baseDir , 'apps/api/.code-pushup/report.md' ) ,
57
+ json : path . join (
58
+ repo . baseDir ,
59
+ 'apps/api/.code-pushup/report.json' ,
60
+ ) ,
61
+ md : path . join ( repo . baseDir , 'apps/api/.code-pushup/report.md' ) ,
59
62
} ,
60
63
} ,
61
64
} ,
62
65
] ) ,
63
66
} satisfies RunResult ) ;
64
67
65
68
await expect (
66
- readJsonFile ( join ( repo . baseDir , 'apps/api/.code-pushup/report.json' ) ) ,
69
+ readJsonFile (
70
+ path . join ( repo . baseDir , 'apps/api/.code-pushup/report.json' ) ,
71
+ ) ,
67
72
) . resolves . toEqual (
68
73
expect . objectContaining ( {
69
74
plugins : [
@@ -79,7 +84,9 @@ describe('CI - monorepo mode (Nx)', () => {
79
84
} ) ,
80
85
) ;
81
86
await expect (
82
- readJsonFile ( join ( repo . baseDir , 'libs/ui/.code-pushup/report.json' ) ) ,
87
+ readJsonFile (
88
+ path . join ( repo . baseDir , 'libs/ui/.code-pushup/report.json' ) ,
89
+ ) ,
83
90
) . resolves . toEqual (
84
91
expect . objectContaining ( {
85
92
plugins : [
@@ -104,21 +111,24 @@ describe('CI - monorepo mode (Nx)', () => {
104
111
await git . checkoutLocalBranch ( 'feature-1' ) ;
105
112
106
113
await rename (
107
- join ( repo . baseDir , 'apps/api/src/index.js' ) ,
108
- join ( repo . baseDir , 'apps/api/src/index.ts' ) ,
114
+ path . join ( repo . baseDir , 'apps/api/src/index.js' ) ,
115
+ path . join ( repo . baseDir , 'apps/api/src/index.ts' ) ,
109
116
) ;
110
117
await rename (
111
- join ( repo . baseDir , 'apps/web/src/index.ts' ) ,
112
- join ( repo . baseDir , 'apps/web/src/index.js' ) ,
118
+ path . join ( repo . baseDir , 'apps/web/src/index.ts' ) ,
119
+ path . join ( repo . baseDir , 'apps/web/src/index.js' ) ,
113
120
) ;
114
121
await rename (
115
- join ( repo . baseDir , 'libs/ui/code-pushup.config.js' ) ,
116
- join ( repo . baseDir , 'libs/ui/code-pushup.config.ts' ) ,
122
+ path . join ( repo . baseDir , 'libs/ui/code-pushup.config.js' ) ,
123
+ path . join ( repo . baseDir , 'libs/ui/code-pushup.config.ts' ) ,
117
124
) ;
118
125
await writeFile (
119
- join ( repo . baseDir , 'libs/ui/project.json' ) ,
126
+ path . join ( repo . baseDir , 'libs/ui/project.json' ) ,
120
127
(
121
- await readFile ( join ( repo . baseDir , 'libs/ui/project.json' ) , 'utf8' )
128
+ await readFile (
129
+ path . join ( repo . baseDir , 'libs/ui/project.json' ) ,
130
+ 'utf8' ,
131
+ )
122
132
) . replace ( 'code-pushup.config.js' , 'code-pushup.config.ts' ) ,
123
133
) ;
124
134
@@ -135,21 +145,27 @@ describe('CI - monorepo mode (Nx)', () => {
135
145
await expect ( runInCI ( refs , MOCK_API , options , git ) ) . resolves . toEqual ( {
136
146
mode : 'monorepo' ,
137
147
commentId : MOCK_COMMENT . id ,
138
- diffPath : join ( repo . baseDir , '.code-pushup/merged-report-diff.md' ) ,
148
+ diffPath : path . join ( repo . baseDir , '.code-pushup/merged-report-diff.md' ) ,
139
149
projects : expect . arrayContaining < ProjectRunResult > ( [
140
150
{
141
151
name : 'web' ,
142
152
files : {
143
153
report : {
144
- json : join ( repo . baseDir , 'apps/web/.code-pushup/report.json' ) ,
145
- md : join ( repo . baseDir , 'apps/web/.code-pushup/report.md' ) ,
154
+ json : path . join (
155
+ repo . baseDir ,
156
+ 'apps/web/.code-pushup/report.json' ,
157
+ ) ,
158
+ md : path . join ( repo . baseDir , 'apps/web/.code-pushup/report.md' ) ,
146
159
} ,
147
160
diff : {
148
- json : join (
161
+ json : path . join (
149
162
repo . baseDir ,
150
163
'apps/web/.code-pushup/report-diff.json' ,
151
164
) ,
152
- md : join ( repo . baseDir , 'apps/web/.code-pushup/report-diff.md' ) ,
165
+ md : path . join (
166
+ repo . baseDir ,
167
+ 'apps/web/.code-pushup/report-diff.md' ,
168
+ ) ,
153
169
} ,
154
170
} ,
155
171
newIssues : [
@@ -166,15 +182,15 @@ describe('CI - monorepo mode (Nx)', () => {
166
182
} satisfies RunResult ) ;
167
183
168
184
const mdPromise = readFile (
169
- join ( repo . baseDir , '.code-pushup/merged-report-diff.md' ) ,
185
+ path . join ( repo . baseDir , '.code-pushup/merged-report-diff.md' ) ,
170
186
'utf8' ,
171
187
) ;
172
188
await expect ( mdPromise ) . resolves . toBeTruthy ( ) ;
173
189
const md = await mdPromise ;
174
190
await expect (
175
191
md . replace ( / [ \d a - f ] { 40 } / g, '`<commit-sha>`' ) ,
176
192
) . toMatchFileSnapshot (
177
- join ( TEST_SNAPSHOTS_DIR , 'nx-monorepo-report-diff.md' ) ,
193
+ path . join ( TEST_SNAPSHOTS_DIR , 'nx-monorepo-report-diff.md' ) ,
178
194
) ;
179
195
} ) ;
180
196
} ) ;
0 commit comments