File tree 4 files changed +117
-3
lines changed
packages/vitest/src/node/plugins
coverage-report-tests/__snapshots__
4 files changed +117
-3
lines changed Original file line number Diff line number Diff line change 1
1
import MagicString from 'magic-string'
2
2
import type { Plugin } from 'vite'
3
3
import { stripLiteral } from 'strip-literal'
4
+ import { cleanUrl } from 'vite-node/utils'
4
5
5
6
// so people can reassign envs at runtime
6
7
// import.meta.env.VITE_NAME = 'app' -> process.env.VITE_NAME = 'app'
@@ -27,7 +28,12 @@ export const EnvReplacerPlugin = (): Plugin => {
27
28
if ( s ) {
28
29
return {
29
30
code : s . toString ( ) ,
30
- map : s . generateMap ( { hires : true , source : id } ) ,
31
+ map : s . generateMap ( {
32
+ hires : true ,
33
+
34
+ // Remove possible query parameters, e.g. vue's "?vue&type=script&src=true&lang.ts"
35
+ source : cleanUrl ( id ) ,
36
+ } ) ,
31
37
}
32
38
}
33
39
} ,
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ exports[`c8 json report 1`] = `
70
70
" 0" : 1 ,
71
71
" 1" : 0 ,
72
72
" 2" : 2 ,
73
+ " 3" : 0 ,
73
74
},
74
75
" fnMap" : {
75
76
" 0" : {
@@ -144,6 +145,30 @@ exports[`c8 json report 1`] = `
144
145
},
145
146
" name" : " coveredMethod" ,
146
147
},
148
+ " 3" : {
149
+ " decl" : {
150
+ " end" : {
151
+ " column" : 6 ,
152
+ " line" : 22 ,
153
+ },
154
+ " start" : {
155
+ " column" : 4 ,
156
+ " line" : 20 ,
157
+ },
158
+ },
159
+ " line" : 20 ,
160
+ " loc" : {
161
+ " end" : {
162
+ " column" : 6 ,
163
+ " line" : 22 ,
164
+ },
165
+ " start" : {
166
+ " column" : 4 ,
167
+ " line" : 20 ,
168
+ },
169
+ },
170
+ " name" : " uncoveredMethodUsingImportMeta" ,
171
+ },
147
172
},
148
173
" path" : " <process-cwd>/src/Counter/Counter.component.ts" ,
149
174
" s" : {
@@ -160,6 +185,10 @@ exports[`c8 json report 1`] = `
160
185
" 18" : 1 ,
161
186
" 19" : 1 ,
162
187
" 2" : 1 ,
188
+ " 20" : 0 ,
189
+ " 21" : 0 ,
190
+ " 22" : 1 ,
191
+ " 23" : 1 ,
163
192
" 3" : 1 ,
164
193
" 4" : 1 ,
165
194
" 5" : 1 ,
@@ -271,7 +300,7 @@ exports[`c8 json report 1`] = `
271
300
},
272
301
" 18" : {
273
302
" end" : {
274
- " column" : 4 ,
303
+ " column" : 0 ,
275
304
" line" : 19 ,
276
305
},
277
306
" start" : {
@@ -281,7 +310,7 @@ exports[`c8 json report 1`] = `
281
310
},
282
311
" 19" : {
283
312
" end" : {
284
- " column" : 2 ,
313
+ " column" : 38 ,
285
314
" line" : 20 ,
286
315
},
287
316
" start" : {
@@ -299,6 +328,46 @@ exports[`c8 json report 1`] = `
299
328
" line" : 3 ,
300
329
},
301
330
},
331
+ " 20" : {
332
+ " end" : {
333
+ " column" : 94 ,
334
+ " line" : 21 ,
335
+ },
336
+ " start" : {
337
+ " column" : 0 ,
338
+ " line" : 21 ,
339
+ },
340
+ },
341
+ " 21" : {
342
+ " end" : {
343
+ " column" : 6 ,
344
+ " line" : 22 ,
345
+ },
346
+ " start" : {
347
+ " column" : 0 ,
348
+ " line" : 22 ,
349
+ },
350
+ },
351
+ " 22" : {
352
+ " end" : {
353
+ " column" : 4 ,
354
+ " line" : 23 ,
355
+ },
356
+ " start" : {
357
+ " column" : 0 ,
358
+ " line" : 23 ,
359
+ },
360
+ },
361
+ " 23" : {
362
+ " end" : {
363
+ " column" : 2 ,
364
+ " line" : 24 ,
365
+ },
366
+ " start" : {
367
+ " column" : 0 ,
368
+ " line" : 24 ,
369
+ },
370
+ },
302
371
" 3" : {
303
372
" end" : {
304
373
" column" : 18 ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ exports[`istanbul json report 1`] = `
9
9
" 0" : 1 ,
10
10
" 1" : 0 ,
11
11
" 2" : 2 ,
12
+ " 3" : 0 ,
12
13
},
13
14
" fnMap" : {
14
15
" 0" : {
@@ -80,13 +81,37 @@ exports[`istanbul json report 1`] = `
80
81
},
81
82
" name" : " (anonymous_2)" ,
82
83
},
84
+ " 3" : {
85
+ " decl" : {
86
+ " end" : {
87
+ " column" : 37 ,
88
+ " line" : 20 ,
89
+ },
90
+ " start" : {
91
+ " column" : 4 ,
92
+ " line" : 20 ,
93
+ },
94
+ },
95
+ " loc" : {
96
+ " end" : {
97
+ " column" : null ,
98
+ " line" : 22 ,
99
+ },
100
+ " start" : {
101
+ " column" : 37 ,
102
+ " line" : 20 ,
103
+ },
104
+ },
105
+ " name" : " (anonymous_3)" ,
106
+ },
83
107
},
84
108
" path" : " <process-cwd>/src/Counter/Counter.component.ts" ,
85
109
" s" : {
86
110
" 0" : 1 ,
87
111
" 1" : 1 ,
88
112
" 2" : 0 ,
89
113
" 3" : 2 ,
114
+ " 4" : 0 ,
90
115
},
91
116
" statementMap" : {
92
117
" 0" : {
@@ -129,6 +154,16 @@ exports[`istanbul json report 1`] = `
129
154
" line" : 17 ,
130
155
},
131
156
},
157
+ " 4" : {
158
+ " end" : {
159
+ " column" : null ,
160
+ " line" : 21 ,
161
+ },
162
+ " start" : {
163
+ " column" : 6 ,
164
+ " line" : 21 ,
165
+ },
166
+ },
132
167
},
133
168
},
134
169
" <process-cwd>/src/Counter/Counter.vue" : {
Original file line number Diff line number Diff line change @@ -16,5 +16,9 @@ export default defineComponent({
16
16
coveredMethod ( ) {
17
17
return 'This line should be covered'
18
18
} ,
19
+
20
+ uncoveredMethodUsingImportMeta ( ) {
21
+ return `Source maps tend to break when import meta is used: ${ import . meta. env . BASE_URL } `
22
+ } ,
19
23
} ,
20
24
} )
You can’t perform that action at this time.
0 commit comments