You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more details, please refer to the [Configuration](/config) section.
54
58
@@ -68,7 +72,18 @@ export default defineConfig({
68
72
69
73
### Code transformation
70
74
71
-
Rstest uses `swc` for code transformation by default, which is different from Jest's `babel-jest`. Most of the time, you don't need to change anything.
75
+
Rstest uses `swc` for code transformation by default, which is different from Jest's `babel-jest`. Most of the time, you don't need to change anything. And you can configure your swc options through [tools.swc](/config/build/tools#toolsswc).
76
+
77
+
```diff
78
+
export default {
79
+
- transform: {
80
+
- '^.+\\.(t|j)sx?$': ['@swc/jest', {}],
81
+
- },
82
+
+ tools: {
83
+
+ swc: {}
84
+
+ }
85
+
}
86
+
```
72
87
73
88
However, if you have custom Babel configurations or use specific Babel plugins/presets, you can add [Rsbuild's Babel Plugin](https://rsbuild.rs/plugins/list/plugin-babel):
74
89
@@ -83,6 +98,8 @@ export default defineConfig({
83
98
84
99
## Update test API
85
100
101
+
### Test API
102
+
86
103
Your existing Jest test files should work with minimal changes since Rstest provides Jest-compatible APIs. Simply update your imports from Jest to Rstest:
87
104
88
105
```diff
@@ -98,3 +115,25 @@ Rstest provides a `rstest` API that you can use to access Rstest's utilities, su
98
115
99
116
fn.mockResolvedValue('foo');
100
117
```
118
+
119
+
### Done callback
120
+
121
+
The `done` callback is not supported in Rstest. Instead, you can return a Promise or use `async/await` for asynchronous tests.
122
+
123
+
```diff
124
+
- test('async test with done', (done) => {
125
+
+ test('async test with done', () => new Promise(done => {
126
+
// ...
127
+
done();
128
+
- });
129
+
+ }));
130
+
```
131
+
132
+
### Timeout
133
+
134
+
If you used `jest.setTimeout()` to set the timeout for a test, you can use `rstest.setConfig()` instead.
0 commit comments