Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '../types/config'
import type { BaseCoverageOptions, CoverageReporterWithOptions } from '../types/coverage'
import crypto from 'node:crypto'
import { basename } from 'node:path'
import { pathToFileURL } from 'node:url'
import { slash, toArray } from '@vitest/utils/helpers'
import { resolveModule } from 'local-pkg'
Expand Down Expand Up @@ -394,7 +395,7 @@ export function resolveConfig(

// Add hard-coded default coverage exclusions. These cannot be overidden by user config.
// Override original exclude array for cases where user re-uses same object in test.exclude.
resolved.coverage.exclude = [
resolved.coverage.exclude = [...new Set([
...resolved.coverage.exclude,

// Exclude setup files
Expand All @@ -410,15 +411,15 @@ export function resolveConfig(
...resolved.include,

// Configs
resolved.config && slash(resolved.config),
resolved.config && basename(slash(resolved.config)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show example what cases this fixes? Does the configuration file show up in coverage in some cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitest

As shown in the image above, resolved.config contains the full path, but it should be the same file as the second value in the configFiles array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it cause issues with full path? For example, if you use vitest --config some-custom-config.ts, does that show up in coverage report?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't seem to cause any problems at the moment. Actually, this PR wasn't initially intended to address this issue.

Initially, it was here: #9348 (comment). My configuration caused the configuration content to be loaded twice, resulting in duplicate content in the second load. So, I wanted to remove duplicates.

Later, with @sheremet-va's guidance #9348 (comment), I adjusted the configuration so that Vitest's configuration loading logic worked correctly, loading only once. Then I noticed that this configuration file might also be duplicated, so I tried removing duplicates there as well. Of course, I think it's probably fine not to modify this one.

...configFiles,

// Vite internal
'**\/virtual:*',
'**\/__x00__*',

'**/node_modules/**',
].filter(pattern => typeof pattern === 'string')
])].filter(pattern => typeof pattern === 'string')

resolved.forceRerunTriggers = [
...resolved.forceRerunTriggers,
Expand Down
Loading