-
Notifications
You must be signed in to change notification settings - Fork 122
feat: support rstest in testing library #2328
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
Merged
Merged
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
582ffe8
Squashed commit of the following:
upupming 49afabb
fix: test cases
upupming 2f22d7d
fix: use-sync-external-store test cases
upupming 88ec796
fix: expect for rstest
upupming f5a3757
feat: support rstest-adapter in testing library (#2347)
9aoy 222a3b6
Merge branch 'main' into feat/rstest-rltl
upupming c493518
fix: rstest lock version (#2349)
9aoy 62a1481
Update .github/workflows/test.yml
upupming ee27d39
Update packages/react/testing-library/.npmignore
upupming 0773651
Update packages/react/testing-library/src/__tests__/css/index.test.jsx
upupming f581194
Update packages/react/testing-library/src/setupFiles/common/runtime-s…
upupming 1c8cf5f
feat: add rstest support to testing-environment
upupming 340592e
fix: align rstest environment and test loader options
upupming b1636a3
test: stabilize rstest list snapshot
upupming b5ebec8
Merge remote-tracking branch 'origin/main' into feat/rstest-rltl
upupming f79bc80
Merge remote-tracking branch 'origin/main' into feat/rstest-rltl
upupming dcd3dd3
Update .github/workflows/test.yml
upupming e6dee15
Merge origin/main into feat/rstest-rltl
upupming 8b0aad1
fix(testing-library): externalize rstest dependencies
upupming df3ae29
Merge remote-tracking branch 'origin/main' into feat/rstest-rltl
upupming 014ff38
Revert "fix(testing-library): externalize rstest dependencies"
upupming f50b0a5
fix: test snapshots
upupming e239639
fix: remove extra code
upupming 2a6f4c5
Merge branch 'main' into feat/rstest-rltl
upupming 085aed9
refactor(testing-library): deprecate createVitestConfig and adopt plu…
upupming c2f397d
refactor(testing-library): replace rstest-adapter with rstest-config
upupming 41c16b2
chore: dedupe pnpm lockfile
upupming 8fae035
fix: address rstest review comments
upupming b5e9180
revert: remove rspeedy peer dependency from react package
upupming 333198d
chore: remove rstest peer dependency from react package
upupming b30dd88
chore: sync lockfile after removing rstest core
upupming a4c440a
Merge remote-tracking branch 'origin/main' into feat/rstest-rltl
upupming b77f622
fix: regenerate lockfile after merge
upupming 6521e71
fix: add explicit type for profileFlowId
upupming 5722509
fix: use runtime worklet-runtime paths in testing setup
upupming 99592d3
test: fix vitest snapshot and defineDCE output assertion
upupming 527ed7c
Merge remote-tracking branch 'origin/main' into feat/rstest-rltl
upupming 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@lynx-js/react-webpack-plugin": patch | ||
| "@lynx-js/react-rsbuild-plugin": patch | ||
| --- | ||
|
|
||
| Support rstest for testing library using a dedicated testing loader. |
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,11 @@ | ||
| --- | ||
| "@lynx-js/testing-environment": minor | ||
| --- | ||
|
|
||
| **BREAKING CHANGE**: | ||
|
|
||
| Align the public test-environment API around `LynxEnv`. | ||
|
|
||
| `LynxTestingEnv` now expects a `{ window }`-shaped environment instead of relying on a concrete `JSDOM` instance or `global.jsdom`. Callers that construct `LynxTestingEnv` manually or initialize the environment through globals should migrate to `new LynxTestingEnv({ window })` or set `global.lynxEnv`. | ||
|
|
||
| This release also adds the `@lynx-js/testing-environment/env/rstest` entry for running the shared testing-environment suite under rstest. |
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,5 @@ | ||
| --- | ||
| "create-rspeedy": patch | ||
| --- | ||
|
|
||
| Add Rstest ReactLynx Testing Library template. |
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,26 @@ | ||
| --- | ||
| "@lynx-js/react": patch | ||
| --- | ||
|
|
||
| Support rstest for testing library, you can use rstest with RLTL now: | ||
|
|
||
| Create a config file `rstest.config.ts` with the following content: | ||
|
|
||
| ```ts | ||
| import { defineConfig } from '@rstest/core'; | ||
| import { withLynxConfig } from '@lynx-js/react/testing-library/rstest-config'; | ||
|
|
||
| export default defineConfig({ | ||
| extends: withLynxConfig(), | ||
| }); | ||
| ``` | ||
|
|
||
| `@lynx-js/react/testing-library/rstest-config` will automatically load your `lynx.config.ts` and apply the same configuration to rstest, so you can keep your test environment consistent with your development environment. | ||
|
|
||
| And then use rstest as usual: | ||
|
|
||
| ```bash | ||
| $ rstest | ||
| ``` | ||
|
|
||
| For more usage detail, see https://rstest.rs/ |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| * | ||
| !dist/* | ||
| !dist/env/* | ||
| * | ||
| !dist | ||
| !dist/**/* | ||
| !types | ||
| !types/* | ||
|
upupming marked this conversation as resolved.
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { defineConfig } from '@rstest/core'; | ||
| import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'; | ||
| import { withDefaultConfig } from './src/rstest-config.ts'; | ||
|
|
||
| export default defineConfig({ | ||
| extends: withDefaultConfig({ | ||
| modifyRstestConfig(config) { | ||
| return { | ||
| ...config, | ||
| tools: { | ||
| swc: { | ||
| jsc: { | ||
| transform: { | ||
| useDefineForClassFields: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| plugins: [ | ||
| ...(config.plugins || []), | ||
| pluginReactLynx(), | ||
| ], | ||
| source: { | ||
| ...config.source, | ||
| define: { | ||
| ...config.source?.define, | ||
| __ALOG__: 'true', | ||
| }, | ||
| }, | ||
| resolve: { | ||
| ...config.resolve, | ||
| // in order to make our test case work for | ||
| // both vitest and rstest, we need to alias | ||
| // `vitest` to `@rstest/core` | ||
| alias: { | ||
| ...config.resolve?.alias, | ||
| vitest: require.resolve('./vitest-polyfill.cjs'), | ||
| }, | ||
| }, | ||
| include: ['src/**/*.test.{js,jsx,ts,tsx}', '!src/__tests__/3.1/**/*.{js,jsx,ts,tsx}'], | ||
| }; | ||
| }, | ||
| }), | ||
| }); |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.