-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
dev: adapt to vitest@1.2 #213
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,14 +281,6 @@ export class TestWatcher extends Disposable { | |
} | ||
|
||
function getSourceFilepathAndLocationFromStack(stack: ParsedStack): { sourceFilepath?: string; line: number; column: number } { | ||
if (stack.sourcePos) { | ||
return { | ||
sourceFilepath: stack.sourcePos.source?.replace(/\//g, path.sep), | ||
line: stack.sourcePos.line, | ||
column: stack.sourcePos.column, | ||
} | ||
} | ||
|
||
return { | ||
sourceFilepath: stack.file.replace(/\//g, path.sep), | ||
line: stack.line, | ||
|
@@ -362,8 +354,8 @@ export function syncTestStatusToVsCode( | |
) { | ||
const set = new Set(vscode) | ||
for (const task of vitest) { | ||
const data = matchTask(task, set, task.type) | ||
if (task.type === 'test') { | ||
const data = matchTask(task, set) | ||
if (task.type === 'test' || task.type === 'custom') { | ||
if (task.result == null) { | ||
if (finished) { | ||
finishedTest && finishedTest.add(data.item) | ||
|
@@ -385,7 +377,7 @@ export function syncTestStatusToVsCode( | |
case 'fail': | ||
run.failed( | ||
data.item, | ||
testMessageForTestError(data.item, task.result.error), | ||
task.result.errors?.map(i => testMessageForTestError(data.item, i)) ?? [], | ||
task.result.duration, | ||
) | ||
finishedTest && finishedTest.add(data.item) | ||
|
@@ -414,14 +406,13 @@ export function syncTestStatusToVsCode( | |
function matchTask( | ||
task: Task, | ||
candidates: Set<TestDescribe | TestCase>, | ||
type: 'suite' | 'test', | ||
): TestDescribe | TestCase { | ||
let ans: (TestDescribe | TestCase) | undefined | ||
for (const candidate of candidates) { | ||
if (type === 'suite' && !(candidate instanceof TestDescribe)) | ||
if (task.type === 'suite' && !(candidate instanceof TestDescribe)) | ||
continue | ||
|
||
if (type === 'test' && !(candidate instanceof TestCase)) | ||
if (task.type === 'test' && !(candidate instanceof TestCase)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what's type='custom'. It should be treated as which one? It seems to be newly introduced in v1. |
||
continue | ||
|
||
if (candidate.pattern === task.name) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This statement throws "Invalid URL" error during activation (from
node_modules/vite/dist/node-cjs/publicUtils.cjs
. That file includes codes like below:It won't work in the bundled
dist/extension.js
. I couldn't find any solution and gave up. Are anyone knows something?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.
I would expect Vite to not be bundled with this extension, maybe it can be externalized/tree-shaken?
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.
vitest/config
doesn't actually import anything from Vite, so I'm not sure why it even gets bundled here 🤔 (Oh, now I see it re-exportsmergeConfig
). I think we should just update the bundler here to remove themergeConfig
API fromvitest/config
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.
It looks like tsup/esbuild's default tree-shaking is not doing much and keeps unused
require("vite")
. Actually tsup supports rollup-based tree-shaking https://tsup.egoist.dev/#tree-shaking, so this config seems to work but rebuild slows down a bit.Personally, just inlining
defaultInclude
anddefaultExclude
is equally fine as well.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.
tsup also supports plugins where we can manually remove vite import
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.
Yes
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.
It is ideal to import the original config from vitest. I think it's problem of vitest bundle.
new URL
with relative path resolution won't work imported bundle. Anyway, can it be acceptable?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.
it is not the problem of Vitest bundle, Vitest doesn't use
new URL
, this is the code from Vite, and Vite should not be bundled for the extension. To remove vite import, you can write a small esbuild plugin that strips it outThere 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.
Ok, let's keep hardcoded config for now
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.
Also, I wonder if
require
would work: