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
Copy file name to clipboardExpand all lines: docs/config/index.md
+14-27Lines changed: 14 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1120,41 +1120,28 @@ Will call [`vi.unstubAllEnvs`](/api/vi#vi-unstuballenvs) before each test.
1120
1120
1121
1121
Will call [`vi.unstubAllGlobals`](/api/vi#vi-unstuballglobals) before each test.
1122
1122
1123
-
### transformMode
1123
+
### testTransformMode
1124
1124
1125
-
-**Type:**`{ web?, ssr? }`
1125
+
-**Type:**`{ web?, ssr? }`
1126
+
-**Version:** Since Vitest 0.32.0
1126
1127
1127
-
Determine the transform method of modules
1128
+
Determine the transform method for all modules inported inside a test that matches the glob pattern. By default, relies on the environment. For example, tests with JSDOM environment will process all files with `ssr: false` flag and tests with Node environment process all modules with `ssr: true`.
1128
1129
1129
-
#### transformMode.ssr
1130
+
#### testTransformMode.ssr
1130
1131
1131
-
-**Type:**`RegExp[]`
1132
-
-**Default:**`[/\.([cm]?[jt]sx?|json)$/]`
1132
+
-**Type:**`string[]`
1133
+
-**Default:**`[]`
1133
1134
1134
-
Use SSR transform pipeline for the specified files.<br>
1135
-
Vite plugins will receive `ssr: true` flag when processing those files.
1135
+
Use SSR transform pipeline for all modules inside specified tests.<br>
1136
+
Vite plugins will receive `ssr: true` flag when processing those files.
1136
1137
1137
-
#### transformMode.web
1138
+
#### testTransformMode.web
1138
1139
1139
-
-**Type:**`RegExp[]`
1140
-
-**Default:***modules other than those specified in `transformMode.ssr`*
1140
+
-**Type:**`string[]`
1141
+
-**Default:**`[]`
1141
1142
1142
-
First do a normal transform pipeline (targeting browser), then do a SSR rewrite to run the code in Node.<br>
1143
-
Vite plugins will receive `ssr: false` flag when processing those files.
1144
-
1145
-
When you use JSX as component models other than React (e.g. Vue JSX or SolidJS), you might want to config as following to make `.tsx` / `.jsx` transformed as client-side components:
1146
-
1147
-
```ts
1148
-
import { defineConfig } from'vitest/config'
1149
-
1150
-
exportdefaultdefineConfig({
1151
-
test: {
1152
-
transformMode: {
1153
-
web: [/\.[jt]sx$/],
1154
-
},
1155
-
},
1156
-
})
1157
-
```
1143
+
First do a normal transform pipeline (targeting browser), then do a SSR rewrite to run the code in Node.<br>
1144
+
Vite plugins will receive `ssr: false` flag when processing those files.
0 commit comments