Skip to content

test: fix playground config variants#13725

Merged
patak-cat merged 4 commits intomainfrom
test/fix-custom-config-files
Jul 7, 2023
Merged

test: fix playground config variants#13725
patak-cat merged 4 commits intomainfrom
test/fix-custom-config-files

Conversation

@patak-cat
Copy link
Member

Description

Our current test setup for config variants loaded the config files from the original playground folder instead of the playground-temp copy. This caused issues when using __dirname to resolve paths. I'm surprised that the tests were working. This is the issue discovered in #13712 in this comment.

It worked by looking for a vite.config.* file in the folder of the playground variant spec.

/playground/assets/__tests__/relative_path/assets-relative-path.spec.js
/playground/assets/__tests__/relative_path/vite.config.js

But the files inside __tests__ are not copied to playground-temp.

Most of these config files were a re-export of the config defined at root.

This PR defines a new convention. For variants, if there is a config named vite.config-{variantName}.js in root, it is then used (these are copied already to playground-temp). We were already using this convention to be able to run the playgrounds outside of Vitest. So we just needed to delete all the vite.config.js files inside __tests__ (the only ones that were different were for worker sourcemap, but I reworked them... it is better because we can now run them out of tests too).


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

I like the new convention 👍

@patak-cat patak-cat merged commit 8f109a6 into main Jul 7, 2023
@patak-cat patak-cat deleted the test/fix-custom-config-files branch July 7, 2023 11:09
sapphi-red added a commit to xinxinhe1810/vite that referenced this pull request Jul 25, 2023
The config will be loaded automatically as vitejs#13725 is merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants