@lynx-js/react 0.118.0 → 0.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/package.json +25 -3
- package/refresh/.turbo/turbo-build.log +1 -1
- package/runtime/lib/alog/elementPAPICall.js +1 -0
- package/runtime/lib/alog/elementPAPICall.js.map +1 -1
- package/runtime/lib/debug/component-stack.d.ts +0 -6
- package/runtime/lib/debug/component-stack.js.map +1 -1
- package/runtime/lib/gesture/processGesture.js +103 -11
- package/runtime/lib/gesture/processGesture.js.map +1 -1
- package/runtime/lib/hooks/mainThread.d.ts +17 -0
- package/runtime/lib/hooks/mainThread.js +152 -0
- package/runtime/lib/hooks/mainThread.js.map +1 -0
- package/runtime/lib/hooks/react.d.ts +1 -2
- package/runtime/lib/hooks/react.js +8 -14
- package/runtime/lib/hooks/react.js.map +1 -1
- package/runtime/lib/lifecycle/event/jsReady.js +3 -1
- package/runtime/lib/lifecycle/event/jsReady.js.map +1 -1
- package/runtime/lib/lifecycle/render.js +0 -6
- package/runtime/lib/lifecycle/render.js.map +1 -1
- package/runtime/lib/renderToOpcodes/constants.d.ts +1 -0
- package/runtime/lib/renderToOpcodes/constants.js +1 -0
- package/runtime/lib/renderToOpcodes/constants.js.map +1 -1
- package/runtime/lib/renderToOpcodes/index.js +3 -1
- package/runtime/lib/renderToOpcodes/index.js.map +1 -1
- package/runtime/lib/tsconfig.tsbuildinfo +1 -1
- package/testing-library/README.md +48 -9
- package/testing-library/dist/0~123.js +43 -0
- package/testing-library/dist/881.js +1 -0
- package/testing-library/dist/entry.d.ts +1 -0
- package/testing-library/dist/env/index.d.ts +2 -0
- package/testing-library/dist/env/index.js +661 -0
- package/testing-library/dist/env/rstest.d.ts +1 -0
- package/testing-library/dist/env/rstest.js +6 -0
- package/testing-library/dist/env/vitest.d.ts +3 -0
- package/testing-library/dist/env/vitest.js +8 -662
- package/testing-library/dist/fire-event.d.ts +111 -0
- package/testing-library/dist/index.d.ts +18 -6
- package/testing-library/dist/plugins/index.d.ts +2 -0
- package/testing-library/dist/plugins/index.js +282 -0
- package/testing-library/dist/plugins/vitest.d.ts +26 -0
- package/testing-library/dist/pure.js +2 -2
- package/testing-library/dist/rstest-config.d.ts +25 -0
- package/testing-library/dist/rstest-config.js +61 -0
- package/testing-library/dist/setupFiles/common/bootstrap.js +2 -0
- package/testing-library/dist/{vitest-global-setup.js → setupFiles/common/runtime-setup.js} +25 -39
- package/testing-library/dist/setupFiles/inner/rstest.js +7 -0
- package/testing-library/dist/setupFiles/inner/vitest.js +11 -0
- package/testing-library/dist/setupFiles/rstest.js +21 -0
- package/testing-library/dist/setupFiles/vitest.js +20 -0
- package/testing-library/dist/vitest.config.d.ts +6 -0
- package/testing-library/dist/vitest.config.js +4 -257
- package/transform/dist/wasm.cjs +1 -1
- package/transform/index.d.ts +10 -0
- package/testing-library/types/vitest-config.d.ts +0 -20
|
@@ -8,30 +8,69 @@ Similar to [react-testing-library](https://github.com/testing-library/react-test
|
|
|
8
8
|
|
|
9
9
|
## Setup
|
|
10
10
|
|
|
11
|
+
### Rstest
|
|
12
|
+
|
|
13
|
+
Setup rstest with `@lynx-js/react/testing-library/rstest-config`.
|
|
14
|
+
|
|
15
|
+
Recommended for library projects:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineConfig } from '@rstest/core';
|
|
19
|
+
import { withDefaultConfig } from '@lynx-js/react/testing-library/rstest-config';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
extends: withDefaultConfig(),
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use `withLynxConfig` when you want to reuse your app's `lynx.config.ts`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// rstest.config.ts
|
|
30
|
+
import { defineConfig } from '@rstest/core';
|
|
31
|
+
import { withLynxConfig } from '@lynx-js/react/testing-library/rstest-config';
|
|
32
|
+
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
extends: withLynxConfig(),
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Difference between `withLynxConfig` and `withDefaultConfig`:
|
|
39
|
+
|
|
40
|
+
- `withLynxConfig`: app-oriented. Loads your `lynx.config.ts` and converts it to rstest config, so rspeedy/lynx settings are reused in tests.
|
|
41
|
+
- `withDefaultConfig`: library-oriented. Only applies testing-library defaults (`jsdom`, setup files, globals) and lets you provide the rest via `modifyRstestConfig`.
|
|
42
|
+
|
|
43
|
+
Then you can start writing tests and run them with rstest!
|
|
44
|
+
|
|
45
|
+
For more usage detail, see https://rstest.rs/
|
|
46
|
+
|
|
47
|
+
### Vitest
|
|
48
|
+
|
|
11
49
|
Setup vitest:
|
|
12
50
|
|
|
13
51
|
```js
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import { createVitestConfig } from '@lynx-js/react/testing-library/vitest-config';
|
|
52
|
+
import { defineConfig } from 'vitest/config';
|
|
53
|
+
import { vitestTestingLibraryPlugin } from '@lynx-js/react/testing-library/plugins';
|
|
17
54
|
|
|
18
|
-
|
|
19
|
-
|
|
55
|
+
export default defineConfig({
|
|
56
|
+
plugins: [
|
|
57
|
+
vitestTestingLibraryPlugin(),
|
|
58
|
+
],
|
|
20
59
|
test: {
|
|
21
60
|
// ...
|
|
22
61
|
},
|
|
23
62
|
});
|
|
24
|
-
|
|
25
|
-
export default mergeConfig(defaultConfig, config);
|
|
26
63
|
```
|
|
27
64
|
|
|
28
65
|
Then you can start writing tests and run them with vitest!
|
|
29
66
|
|
|
67
|
+
`createVitestConfig` is still supported for backward compatibility, but is deprecated.
|
|
68
|
+
|
|
30
69
|
## Usage
|
|
31
70
|
|
|
32
|
-
```
|
|
71
|
+
```jsx
|
|
33
72
|
import '@testing-library/jest-dom';
|
|
34
|
-
import { test, expect } from 'vitest';
|
|
73
|
+
import { test, expect } from 'vitest'; // or '@rstest/core'
|
|
35
74
|
import { render } from '@lynx-js/react/testing-library';
|
|
36
75
|
|
|
37
76
|
test('renders options.wrapper around node', async () => {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
2
|
+
function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
|
|
3
|
+
const { environments, ...rawBuildConfig } = rawRsbuildConfig;
|
|
4
|
+
const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
|
|
5
|
+
const rsbuildConfig = environmentConfig ? mergeRsbuildConfig(rawBuildConfig, environmentConfig) : rawBuildConfig;
|
|
6
|
+
const finalBuildConfig = modifyRsbuildConfig ? modifyRsbuildConfig(rsbuildConfig) : rsbuildConfig;
|
|
7
|
+
const { rspack, swc, bundlerChain } = finalBuildConfig.tools || {};
|
|
8
|
+
const { cssModules, target, module } = finalBuildConfig.output || {};
|
|
9
|
+
const { decorators, define, include, exclude, tsconfigPath } = finalBuildConfig.source || {};
|
|
10
|
+
return {
|
|
11
|
+
root: finalBuildConfig.root,
|
|
12
|
+
name: environmentName,
|
|
13
|
+
plugins: [
|
|
14
|
+
...finalBuildConfig.plugins || [],
|
|
15
|
+
{
|
|
16
|
+
name: 'remove-useless-plugins',
|
|
17
|
+
remove: [
|
|
18
|
+
'rsbuild:type-check'
|
|
19
|
+
],
|
|
20
|
+
setup: ()=>{}
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
source: {
|
|
24
|
+
decorators,
|
|
25
|
+
define,
|
|
26
|
+
include,
|
|
27
|
+
exclude,
|
|
28
|
+
tsconfigPath
|
|
29
|
+
},
|
|
30
|
+
resolve: finalBuildConfig.resolve,
|
|
31
|
+
output: {
|
|
32
|
+
cssModules,
|
|
33
|
+
module
|
|
34
|
+
},
|
|
35
|
+
tools: {
|
|
36
|
+
rspack,
|
|
37
|
+
swc,
|
|
38
|
+
bundlerChain
|
|
39
|
+
},
|
|
40
|
+
testEnvironment: 'node' === target ? 'node' : 'happy-dom'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { toRstestConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createRequire } from "node:module";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from '../../../types/entry.d.ts';
|