-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(coverage): remove unnecessary __vite_ssr_exports__
manipulation
#7132
base: main
Are you sure you want to change the base?
refactor(coverage): remove unnecessary __vite_ssr_exports__
manipulation
#7132
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add test case that validates function counts. We used to have one but looks like it got removed during some test setup refactorings.
So maybe something like:
vitest/test/coverage-test/coverage-report-tests/generic.report.test.ts
Lines 132 to 141 in 7fd341c
test('function count is correct', async () => { | |
const coverageJson = await readCoverageJson() | |
const coverageMap = libCoverage.createCoverageMap(coverageJson as any) | |
const fileCoverage = coverageMap.fileCoverageFor('<process-cwd>/src/function-count.ts') | |
const { functions } = fileCoverage.toSummary() | |
expect(functions.total).toBe(5) | |
expect(functions.covered).toBe(3) | |
}) |
vitest/test/coverage-test/src/function-count.ts
Lines 1 to 36 in 7fd341c
/* | |
* This file should have: | |
* - 5 functions in total | |
* - 3 covered functions | |
* - 2 uncovered functions | |
*/ | |
/* eslint-disable unused-imports/no-unused-vars */ | |
// This function is covered | |
function first() { | |
return 1 | |
} | |
first() | |
// This function is covered | |
export function second() { | |
fifth() | |
return 2 | |
} | |
// This function is NOT covered | |
export function third() { | |
throw new Error('Do not call this function') | |
} | |
// This function is NOT covered | |
function fourth() { | |
return 4 | |
} | |
// This function is covered | |
function fifth() { | |
return 5 | |
} |
It looks like there are several tests related to function count like this snapshot vitest/test/coverage-test/test/__snapshots__/results-v8.snapshot.json Lines 108 to 110 in f9a6284
In #7096, I'm seeing |
Description
Vite SSR doesn't create a mapping for
Object.defineProperty(__vite_ssr_exports__, ...)
(as they are simply injected byMagicString.appendLeft
), so I'm not sure what this replacement on v8 coverage is for.It looks like
test/coverage-test
is passing locally. Let me check others on CI.Sadly, this doesn't seem to entirely help #7130. There's still some odd changes (namely export getter
get
appears in function coverage) in #7096 after applying the same patch.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.