vitest-environment-stencil 1.9.3 → 1.10.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/README.md +71 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
1
|
# vitest-environment-stencil
|
|
2
2
|
|
|
3
|
-
A Vitest environment for testing Stencil components.
|
|
3
|
+
A custom [Vitest environment](https://vitest.dev/guide/environment.html) for testing [Stencil](https://stenciljs.com/) components.
|
|
4
|
+
|
|
5
|
+
This package enables the `environment: 'stencil'` option in your Vitest configuration, providing a DOM environment optimized for Stencil component testing.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev vitest-environment-stencil @stencil/vitest vitest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
In your Vitest config, set the environment to `stencil`:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// vitest.config.ts
|
|
19
|
+
import { defineVitestConfig } from '@stencil/vitest/config';
|
|
20
|
+
|
|
21
|
+
export default defineVitestConfig({
|
|
22
|
+
stencilConfig: './stencil.config.ts',
|
|
23
|
+
test: {
|
|
24
|
+
include: ['src/**/*.spec.{ts,tsx}'],
|
|
25
|
+
environment: 'stencil',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Per-File Environment
|
|
31
|
+
|
|
32
|
+
You can also set the environment on a per-file basis using a comment directive at the top of your test file:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// @vitest-environment stencil
|
|
36
|
+
import { render, h } from '@stencil/vitest';
|
|
37
|
+
|
|
38
|
+
describe('my-component', () => {
|
|
39
|
+
// ...
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This is useful when you have a mix of test types and only some need the Stencil environment.
|
|
44
|
+
|
|
45
|
+
### Environment Options
|
|
46
|
+
|
|
47
|
+
You can configure the underlying DOM implementation using `environmentOptions`:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
export default defineVitestConfig({
|
|
51
|
+
stencilConfig: './stencil.config.ts',
|
|
52
|
+
test: {
|
|
53
|
+
environment: 'stencil',
|
|
54
|
+
environmentOptions: {
|
|
55
|
+
stencil: {
|
|
56
|
+
// Choose your DOM implementation:
|
|
57
|
+
// 'mock-doc' (default) - Stencil's built-in mock DOM
|
|
58
|
+
// 'jsdom' - Full jsdom implementation (requires jsdom package)
|
|
59
|
+
// 'happy-dom' - Fast happy-dom implementation (requires happy-dom package)
|
|
60
|
+
domEnvironment: 'mock-doc',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
For full documentation, including testing APIs, matchers, and examples, see the [@stencil/vitest README](https://www.npmjs.com/package/@stencil/vitest).
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-environment-stencil",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Custom Vitest environment for Stencil component testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"index.mjs",
|
|
16
|
-
"index.d.ts"
|
|
16
|
+
"index.d.ts",
|
|
17
|
+
"README.md"
|
|
17
18
|
],
|
|
19
|
+
"license": "MIT",
|
|
18
20
|
"keywords": [
|
|
19
21
|
"vitest",
|
|
20
22
|
"environment",
|
|
@@ -29,7 +31,10 @@
|
|
|
29
31
|
"publishConfig": {
|
|
30
32
|
"access": "public"
|
|
31
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@stencil/core": "^4.0.0 || ^5.0.0-0"
|
|
36
|
+
},
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"@stencil/vitest": "1.
|
|
38
|
+
"@stencil/vitest": "1.10.0"
|
|
34
39
|
}
|
|
35
40
|
}
|