-
-
Notifications
You must be signed in to change notification settings - Fork 8
Run frontend unit tests using vitest instead of jest #246
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
Draft
davisagli
wants to merge
6
commits into
main
Choose a base branch
from
vitest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a41541f
Run frontend unit tests using vitest instead of jest
davisagli d8330c6
Restore making ci-test pass if there are no tests
davisagli ddaf587
fix test
davisagli e85ebf4
babel.config.cjs
davisagli 39ea128
Don't turn addons into ESM modules, razzle doesn't fully support it
davisagli cde9be0
update test
davisagli 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 hidden or 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 hidden or 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
17 changes: 0 additions & 17 deletions
17
templates/add-ons/frontend/{{ cookiecutter.__folder_name }}/jest-addon.config.js
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
...cutter.__folder_name }}/packages/{{ cookiecutter.frontend_addon_name }}/vitest.config.mjs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineConfig } from 'vitest/config'; | ||
| import voltoVitestConfig from '@plone/volto/vitest.config.mjs'; | ||
| import path from 'path'; | ||
|
|
||
| export default defineConfig({ | ||
| ...voltoVitestConfig, | ||
| resolve: { | ||
| alias: { | ||
| '@plone/volto': path.resolve(__dirname, '../../core/packages/volto/src'), // Add paths accordingly | ||
| // 'promise-file-reader': require.resolve('promise-file-reader') // Add to identify dependency from package | ||
| }, | ||
| }, | ||
| }); | ||
|
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. Can't the test configuration be in the root folder of the monorepo, as is done with Jest? This way it is not necessary to repeat the configuration when we have more than one package in the monorepo. |
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
What if we have more than one package in the monorepo? Can't we run all the tests at once?
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.
@wesleybl we are just replicating how the ecosystem works. If one package has tests, it should depend on vitest, hence, you have to be able to run it in the package itself. The monorepo is not a buildout. It's a way of tie together NodeJS packages.
You can still run them all at once with pnpm, that's why the --filter option exist.
pnpm --filter mypackage1 --filter mypackage2 exec vitestThe monorepo managers (as in turborepo, etc) also does this, they orchestrate commands through different packages who are meant to act independently.
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.
@sneridagh But generally, in monorepos, it's common for the root test script to run tests for all packages. Shouldn't we expect this here? If not, and someone wants to have more than one package in the monorepo, they would have to "customize" the package.json created by cookieplone. It could be something like: