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
This matcher has been deprecated since expect-type v1.2.0. Use [`toExtend`](#toextend) instead.
39
+
:::
40
+
This matcher checks if expect type extends provided type. It is different from `toEqual` and is more similar to [expect's](/api/expect)`toMatchObject()`. With this matcher, you can check if an object “matches” a type.
This matcher checks if expect type extends provided type. It is different from `toEqual` and is more similar to [expect's](/api/expect)`toMatchObject()`. With this matcher, you can check if an object "matches" a type.
This matcher performs a strict check on object types, ensuring that the expected type matches the provided object type. It's stricter than [`toExtend`](#toextend) and is the recommended choice when working with object types as it's more likely to catch issues like readonly properties.
This matcher only works with plain object types. It will fail for union types and other complex types. For those cases, use [`toExtend`](#toextend) instead.
@@ -187,15 +191,63 @@ Vite 已提供外部化机制,但为降低破坏性,仍保留旧方案;[`s
187
191
188
192
未使用上述高级功能者,升级无感知。
189
193
194
+
<<<<<<< HEAD
190
195
### 移除废弃的 API
196
+
=======
197
+
### `workspace` is Replaced with `projects`
198
+
199
+
The `workspace` configuration option was renamed to [`projects`](/guide/projects) in Vitest 3.2. They are functionally the same, except you cannot specify another file as the source of your workspace (previously you could specify a file that would export an array of projects). Migrating to `projects` is easy, just move the code from `vitest.workspace.js` to `vitest.config.ts`:
-`poolMatchGlobs` config option. Use [`projects`](/guide/projects) instead.
246
+
-`environmentMatchGlobs` config option. Use [`projects`](/guide/projects) instead.
247
+
- Reporter APIs `onCollected`, `onSpecsCollected`, `onPathsCollected`, `onTaskUpdate` and `onFinished`. See [`Reporters API`](/advanced/api/reporters) for new alternatives. These APIs were introduced in Vitest `v3.0.0`.
248
+
-`deps.external`, `deps.inline`, `deps.fallbackCJS` config options. Use `server.deps.external`, `server.deps.inline`, or `server.deps.fallbackCJS` instead.
249
+
-`browser.testerScripts` config option. Use [`browser.testerHtmlPath`](/guide/browser/config#browser-testerhtmlpath) instead.
Vitest does not support the callback style of declaring tests. You can rewrite them to use `async`/`await` functions, or use Promise to mimic the callback style.
Jest 中钩子顺序执行(逐个执行),Vitest 默认并行执行。若想使用 Jest 行为,可配置 [`sequence.hooks`](/config/#sequence-hooks):
354
+
=======
355
+
In Jest hooks are called sequentially (one after another). By default, Vitest runs hooks in a stack. To use Jest's behavior, update [`sequence.hooks`](/config/#sequence-hooks) option:
这不是 Jest 特有功能,但如果之前使用 Jest 的 vue-cli preset,需要安装 [`jest-serializer-vue`](https://github.com/eddyerburgh/jest-serializer-vue) 包,并在 [setupFiles](/config/#setupfiles) 中使用:
395
+
=======
396
+
This is not a Jest-specific feature, but if you previously were using Jest with vue-cli preset, you will need to install [`jest-serializer-vue`](https://github.com/eddyerburgh/jest-serializer-vue) package, and specify it in [`snapshotSerializers`](/config/#snapshotserializers):
When types don't match, `.toEqualTypeOf` and `.toExtend` use a special helper type to produce error messages that are as actionable as possible. But there's a bit of an nuance to understanding them. Since the assertions are written "fluently", the failure should be on the "expected" type, not the "actual" type (`expect<Actual>().toEqualTypeOf<Expected>()`). This means that type errors can be a little confusing - so this library produces a `MismatchInfo` type to try to make explicit what the expectation is. For example:
This is because the TypeScript compiler needs to infer the typearg for the `.toEqualTypeOf({a: ''})` style, and this library can only mark it as a failure by comparing it against a generic `Mismatch` type. So, where possible, use a typearg rather than a concrete type for `.toEqualTypeOf` and `.toExtend`. If it's much more convenient to compare two concrete types, you can use `typeof`:
102
+
>>>>>>> ec2e441b2e5176ed50172b0eed5ac79812b5c578
95
103
96
104
```ts
97
105
const one =valueFromFunctionOne({ some: { complex: inputs } })
0 commit comments