@najemi-software/vitest-dom 0.1.1
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 +27 -0
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/chunk-V52HJAAH.js +1688 -0
- package/dist/chunk-V52HJAAH.js.map +1 -0
- package/dist/extend-expect.js +8 -0
- package/dist/extend-expect.js.map +1 -0
- package/dist/matchers.d.ts +765 -0
- package/dist/matchers.js +57 -0
- package/dist/matchers.js.map +1 -0
- package/extend-expect.d.ts +9 -0
- package/extend-expect.js +1 -0
- package/matchers.d.ts +1 -0
- package/matchers.js +1 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# `vitest-dom`
|
|
2
|
+
|
|
3
|
+
## v0.0.5
|
|
4
|
+
|
|
5
|
+
- Loosened the dependency on `vitest` to allow for versions between 0.16 and 0.30
|
|
6
|
+
- Added missing type export for `toBeDisabled`
|
|
7
|
+
|
|
8
|
+
## v0.0.6
|
|
9
|
+
|
|
10
|
+
- Actually call `extend.expect` in `extend-expect` module (whoops!)
|
|
11
|
+
|
|
12
|
+
## v0.1.0
|
|
13
|
+
|
|
14
|
+
- Bumped peer dependency on `vitest` to `^0.31.0`, as Vitest has made some
|
|
15
|
+
breaking changes to its TypeScript API. We have updated our types to consume
|
|
16
|
+
and extend the new types.
|
|
17
|
+
- We no longer augment the global `expect` type, as this is only desired when
|
|
18
|
+
the user opts in to importing globals from `vitest`. Users will need to
|
|
19
|
+
explicitly follow the Vitest's guidance to get global types.
|
|
20
|
+
- We now use the `css.escape` package to polyfill `CSS.escape` in
|
|
21
|
+
`toHaveFormValues` matcher. This will use the built-in `CSS.escape` if it is
|
|
22
|
+
detected in your runtime.
|
|
23
|
+
|
|
24
|
+
## v0.1.1
|
|
25
|
+
|
|
26
|
+
- Relaxed `peerDependency` on Vitest (#7)
|
|
27
|
+
- Updated internal dependencies
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Kent C. Dodds
|
|
4
|
+
Copyright (c) 2022 Chance Strickland
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
the Software without restriction, including without limitation the rights to
|
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
> [!NOTE]
|
|
2
|
+
> This package (`@najemi-software/vitest-dom`) is a fork of
|
|
3
|
+
> [vitest-dom](https://github.com/chaance/vitest-dom) by
|
|
4
|
+
> [Chance Strickland](https://github.com/chaance), which in turn is a fork of
|
|
5
|
+
> [`@testing-library/jest-dom`](https://github.com/testing-library/jest-dom)
|
|
6
|
+
> and is no longer maintained. All credit for the original work goes to the
|
|
7
|
+
> upstream authors.
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
<h1>vitest-dom</h1>
|
|
11
|
+
|
|
12
|
+
<p>Custom Vitest matchers to test the state of the DOM</p>
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<!-- prettier-ignore-start -->
|
|
19
|
+
[![version][version-badge]][package]
|
|
20
|
+
[![MIT License][license-badge]][license]
|
|
21
|
+
|
|
22
|
+
[![Watch on GitHub][github-watch-badge]][github-watch]
|
|
23
|
+
<!-- prettier-ignore-end -->
|
|
24
|
+
|
|
25
|
+
This library is a fork of
|
|
26
|
+
[`@testing-library/jest-dom`](https://github.com/testing-library/jest-dom). It
|
|
27
|
+
shares that library's implementation and API. It is intended to make it easier to include
|
|
28
|
+
its matchers without clashes between [Vitest][vitest] and Jest's environment or types.
|
|
29
|
+
|
|
30
|
+
See the [`README` for the original package](https://github.com/testing-library/jest-dom/blob/main/README.md) for usage details.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
This module should be installed as one of your project's `devDependencies`:
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
# with npm
|
|
38
|
+
npm install --save-dev @najemi-software/vitest-dom
|
|
39
|
+
# yarn
|
|
40
|
+
yarn add --dev @najemi-software/vitest-dom
|
|
41
|
+
# pnpm
|
|
42
|
+
pnpm add --dev @najemi-software/vitest-dom
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
Import the matchers from `@najemi-software/vitest-dom/matchers` once (perferably in your [tests
|
|
48
|
+
setup file][]), then pass them to Vitest's `expect.extend` method:
|
|
49
|
+
|
|
50
|
+
[tests setup file]: https://vitest.dev/config/#setupfiles
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
// vitest-setup.js
|
|
54
|
+
import * as matchers from "@najemi-software/vitest-dom/matchers";
|
|
55
|
+
import { expect } from "vitest";
|
|
56
|
+
expect.extend(matchers);
|
|
57
|
+
|
|
58
|
+
// or:
|
|
59
|
+
import "@najemi-software/vitest-dom/extend-expect";
|
|
60
|
+
|
|
61
|
+
// In vitest.config.js, add the following
|
|
62
|
+
export default defineConfig({
|
|
63
|
+
test: {
|
|
64
|
+
setupFiles: ["vitest-setup.js"],
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With TypeScript
|
|
70
|
+
|
|
71
|
+
If you're using TypeScript, make sure your setup file has a `.ts` extension to
|
|
72
|
+
include the necessary types.
|
|
73
|
+
|
|
74
|
+
If you import from `@najemi-software/vitest-dom/extend-expect` to run `expect.extend` for you,
|
|
75
|
+
you will get TypeScript support automatically.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
// vitest-setup.ts
|
|
79
|
+
import "@najemi-software/vitest-dom/extend-expect";
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
If you want to run `extend.expect` yourself, you will need to include the type defintions either with a `/// <reference />` directive or including the type in your `compilerOptions`:
|
|
83
|
+
|
|
84
|
+
1. In your test file via a reference directive:
|
|
85
|
+
```typescript
|
|
86
|
+
/// <reference types="@najemi-software/vitest-dom/extend-expect" />
|
|
87
|
+
```
|
|
88
|
+
2. In your `tsconfig.json` via the `types` compiler option:
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"compilerOptions": {
|
|
92
|
+
"types": ["@najemi-software/vitest-dom/extend-expect"]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
<!-- prettier-ignore-start -->
|
|
98
|
+
[vitest]: https://vitest.dev/
|
|
99
|
+
[version-badge]:
|
|
100
|
+
https://img.shields.io/npm/v/@najemi-software/vitest-dom.svg?style=flat-square
|
|
101
|
+
[package]: https://www.npmjs.com/package/@najemi-software/vitest-dom
|
|
102
|
+
[license-badge]:
|
|
103
|
+
https://img.shields.io/npm/l/@najemi-software/vitest-dom.svg?style=flat-square
|
|
104
|
+
[license]: https://github.com/Najemi-Software/vitest-dom/blob/master/LICENSE
|
|
105
|
+
[github-watch-badge]:
|
|
106
|
+
https://img.shields.io/github/watchers/Najemi-Software/vitest-dom.svg?style=social
|
|
107
|
+
[github-watch]: https://github.com/Najemi-Software/vitest-dom/watchers
|
|
108
|
+
<!-- prettier-ignore-end -->
|