Skip to content

Commit ac9e7e8

Browse files
committed
test: adjust coverage config, use v8 coverage
1 parent 29c321b commit ac9e7e8

File tree

19 files changed

+53
-264
lines changed

19 files changed

+53
-264
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"test-e2e": "node scripts/build.js vue -f global -d && vitest -c vitest.e2e.config.ts",
2222
"test-dts": "run-s build-dts test-dts-only",
2323
"test-dts-only": "tsc -p packages-private/dts-built-test/tsconfig.json && tsc -p ./packages-private/dts-test/tsconfig.test.json",
24-
"test-coverage": "vitest -c vitest.unit.config.ts --coverage",
24+
"test-coverage": "vitest run -c vitest.unit.config.ts --coverage",
2525
"test-bench": "vitest bench",
2626
"release": "node scripts/release.js",
2727
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
@@ -71,7 +71,7 @@
7171
"@types/node": "^20.16.2",
7272
"@types/semver": "^7.5.8",
7373
"@types/serve-handler": "^6.1.4",
74-
"@vitest/coverage-istanbul": "^2.0.5",
74+
"@vitest/coverage-v8": "^2.0.5",
7575
"@vue/consolidate": "1.0.0",
7676
"conventional-changelog-cli": "^5.0.0",
7777
"enquirer": "^2.4.1",

packages/compiler-core/src/codegen.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ function genNode(node: CodegenNode | symbol | string, context: CodegenContext) {
725725
!__BROWSER__ && genReturnStatement(node, context)
726726
break
727727

728-
/* istanbul ignore next */
728+
/* v8 ignore start */
729729
case NodeTypes.IF_BRANCH:
730730
// noop
731731
break
@@ -736,6 +736,7 @@ function genNode(node: CodegenNode | symbol | string, context: CodegenContext) {
736736
const exhaustiveCheck: never = node
737737
return exhaustiveCheck
738738
}
739+
/* v8 ignore stop */
739740
}
740741
}
741742

packages/compiler-core/src/compile.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ export function baseCompile(
6868
): CodegenResult {
6969
const onError = options.onError || defaultOnError
7070
const isModuleMode = options.mode === 'module'
71-
/* istanbul ignore if */
71+
/* v8 ignore start */
7272
if (__BROWSER__) {
7373
if (options.prefixIdentifiers === true) {
7474
onError(createCompilerError(ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED))
7575
} else if (isModuleMode) {
7676
onError(createCompilerError(ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED))
7777
}
7878
}
79+
/* v8 ignore stop */
7980

8081
const prefixIdentifiers =
8182
!__BROWSER__ && (options.prefixIdentifiers === true || isModuleMode)

packages/compiler-core/src/transform.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export function createTransformContext(
222222
return `_${helperNameMap[context.helper(name)]}`
223223
},
224224
replaceNode(node) {
225-
/* istanbul ignore if */
225+
/* v8 ignore start */
226226
if (__DEV__) {
227227
if (!context.currentNode) {
228228
throw new Error(`Node being replaced is already removed.`)
@@ -231,9 +231,11 @@ export function createTransformContext(
231231
throw new Error(`Cannot replace root node.`)
232232
}
233233
}
234+
/* v8 ignore stop */
234235
context.parent!.children[context.childIndex] = context.currentNode = node
235236
},
236237
removeNode(node) {
238+
/* v8 ignore next 3 */
237239
if (__DEV__ && !context.parent) {
238240
throw new Error(`Cannot remove root node.`)
239241
}
@@ -243,7 +245,7 @@ export function createTransformContext(
243245
: context.currentNode
244246
? context.childIndex
245247
: -1
246-
/* istanbul ignore if */
248+
/* v8 ignore next 3 */
247249
if (__DEV__ && removalIndex < 0) {
248250
throw new Error(`node being removed is not a child of current parent`)
249251
}

packages/compiler-core/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export function advancePositionWithMutation(
273273
}
274274

275275
export function assert(condition: boolean, msg?: string): void {
276-
/* istanbul ignore if */
276+
/* v8 ignore next 3 */
277277
if (!condition) {
278278
throw new Error(msg || `unexpected compiler condition`)
279279
}

packages/compiler-sfc/src/cache.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { LRUCache } from 'lru-cache'
33
export function createCache<T extends {}>(
44
max = 500,
55
): Map<string, T> | LRUCache<string, T> {
6+
/* v8 ignore next 3 */
67
if (__GLOBAL__ || __ESM_BROWSER__) {
78
return new Map<string, T>()
89
}

packages/runtime-core/src/compat/renderFn.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function convertLegacySlots(vnode: VNode): VNode {
306306
}
307307

308308
export function defineLegacyVNodeProperties(vnode: VNode): void {
309-
/* istanbul ignore if */
309+
/* v8 ignore start */
310310
if (
311311
isCompatEnabled(
312312
DeprecationTypes.RENDER_FUNCTION,
@@ -346,4 +346,5 @@ export function defineLegacyVNodeProperties(vnode: VNode): void {
346346
},
347347
})
348348
}
349+
/* v8 ignore stop */
349350
}

packages/runtime-core/src/component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,8 @@ export function finishComponentSetup(
10601060
// warn missing template/render
10611061
// the runtime compilation of template in SSR is done by server-render
10621062
if (__DEV__ && !Component.render && instance.render === NOOP && !isSSR) {
1063-
/* istanbul ignore if */
10641063
if (!compile && Component.template) {
1064+
/* v8 ignore start */
10651065
warn(
10661066
`Component provided template option but ` +
10671067
`runtime compilation is not supported in this build of Vue.` +
@@ -1073,6 +1073,7 @@ export function finishComponentSetup(
10731073
? ` Use "vue.global.js" instead.`
10741074
: ``) /* should not happen */,
10751075
)
1076+
/* v8 ignore stop */
10761077
} else {
10771078
warn(`Component is missing template or render function: `, Component)
10781079
}
@@ -1208,7 +1209,6 @@ export function getComponentName(
12081209
: Component.name || (includeInferred && Component.__name)
12091210
}
12101211

1211-
/* istanbul ignore next */
12121212
export function formatComponentName(
12131213
instance: ComponentInternalInstance | null,
12141214
Component: ConcreteComponent,

packages/runtime-core/src/components/KeepAlive.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
387387
pattern.lastIndex = 0
388388
return pattern.test(name)
389389
}
390-
/* istanbul ignore next */
390+
/* v8 ignore next */
391391
return false
392392
}
393393

packages/runtime-core/src/components/Suspense.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ function createSuspenseBoundary(
457457
rendererInternals: RendererInternals,
458458
isHydrating = false,
459459
): SuspenseBoundary {
460-
/* istanbul ignore if */
460+
/* v8 ignore start */
461461
if (__DEV__ && !__TEST__ && !hasWarned) {
462462
hasWarned = true
463463
// @ts-expect-error `console.info` cannot be null error
@@ -466,6 +466,7 @@ function createSuspenseBoundary(
466466
`<Suspense> is an experimental feature and its API will likely change.`,
467467
)
468468
}
469+
/* v8 ignore stop */
469470

470471
const {
471472
p: patch,

packages/runtime-core/src/featureFlags.ts

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { getGlobalThis } from '@vue/shared'
44
* This is only called in esm-bundler builds.
55
* It is called when a renderer is created, in `baseCreateRenderer` so that
66
* importing runtime-core is side-effects free.
7-
*
8-
* istanbul-ignore-next
97
*/
108
export function initFeatureFlags(): void {
119
const needWarn = []

packages/runtime-core/src/warning.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export function warn(msg: string, ...args: any[]): void {
6363
)
6464
} else {
6565
const warnArgs = [`[Vue warn]: ${msg}`, ...args]
66-
/* istanbul ignore if */
6766
if (
6867
trace.length &&
6968
// avoid spamming console during tests
7069
!__TEST__
7170
) {
71+
/* v8 ignore next 2 */
7272
warnArgs.push(`\n`, ...formatTrace(trace))
7373
}
7474
console.warn(...warnArgs)
@@ -107,7 +107,7 @@ export function getComponentTrace(): ComponentTraceStack {
107107
return normalizedStack
108108
}
109109

110-
/* istanbul ignore next */
110+
/* v8 ignore start */
111111
function formatTrace(trace: ComponentTraceStack): any[] {
112112
const logs: any[] = []
113113
trace.forEach((entry, i) => {
@@ -131,7 +131,6 @@ function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] {
131131
: [open + close]
132132
}
133133

134-
/* istanbul ignore next */
135134
function formatProps(props: Data): any[] {
136135
const res: any[] = []
137136
const keys = Object.keys(props)
@@ -146,7 +145,6 @@ function formatProps(props: Data): any[] {
146145

147146
function formatProp(key: string, value: unknown): any[]
148147
function formatProp(key: string, value: unknown, raw: true): any
149-
/* istanbul ignore next */
150148
function formatProp(key: string, value: unknown, raw?: boolean): any {
151149
if (isString(value)) {
152150
value = JSON.stringify(value)
@@ -181,3 +179,4 @@ export function assertNumber(val: unknown, type: string): void {
181179
warn(`${type} is NaN - ` + 'the duration expression might be incorrect.')
182180
}
183181
}
182+
/* v8 ignore stop */

packages/runtime-dom/src/components/Transition.ts

-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ export function getTransitionInfo(
397397
let type: CSSTransitionInfo['type'] = null
398398
let timeout = 0
399399
let propCount = 0
400-
/* istanbul ignore if */
401400
if (expectedType === TRANSITION) {
402401
if (transitionTimeout > 0) {
403402
type = TRANSITION

packages/runtime-dom/src/helpers/useCssModule.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { getCurrentInstance, warn } from '@vue/runtime-core'
22
import { EMPTY_OBJ } from '@vue/shared'
33

44
export function useCssModule(name = '$style'): Record<string, string> {
5-
/* istanbul ignore else */
65
if (!__GLOBAL__) {
76
const instance = getCurrentInstance()!
87
if (!instance) {
@@ -22,9 +21,11 @@ export function useCssModule(name = '$style'): Record<string, string> {
2221
}
2322
return mod as Record<string, string>
2423
} else {
24+
/* v8 ignore start */
2525
if (__DEV__) {
2626
warn(`useCssModule() is not supported in the global build.`)
2727
}
2828
return EMPTY_OBJ
29+
/* v8 ignore stop */
2930
}
3031
}

packages/runtime-dom/src/helpers/useCssVars.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>): void {
2020
if (!__BROWSER__ && !__TEST__) return
2121

2222
const instance = getCurrentInstance()
23-
/* istanbul ignore next */
23+
/* v8 ignore start */
2424
if (!instance) {
2525
__DEV__ &&
2626
warn(`useCssVars is called without current active component instance.`)
2727
return
2828
}
29+
/* v8 ignore stop */
2930

3031
const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
3132
Array.from(

packages/shared/src/looseEqual.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export function looseEqual(a: any, b: any): boolean {
2929
aValidType = isObject(a)
3030
bValidType = isObject(b)
3131
if (aValidType || bValidType) {
32-
/* istanbul ignore if: this if will probably never be called */
3332
if (!aValidType || !bValidType) {
3433
return false
3534
}

packages/vue/src/dev.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { initCustomFormatter } from '@vue/runtime-dom'
22

33
export function initDev(): void {
44
if (__BROWSER__) {
5-
/* istanbul ignore if */
65
if (!__ESM_BUNDLER__) {
76
console.info(
87
`You are running a development build of Vue.\n` +

0 commit comments

Comments
 (0)