vitest-environment-stencil

Custom Vitest environment for Stencil component testing

MIT 60 个版本
安装
npm install vitest-environment-stencil
yarn add vitest-environment-stencil
pnpm add vitest-environment-stencil
bun add vitest-environment-stencil
README

vitest-environment-stencil

A custom Vitest environment for testing Stencil components.

This package enables the environment: 'stencil' option in your Vitest configuration, providing a DOM environment optimized for Stencil component testing.

Installation

npm install --save-dev vitest-environment-stencil @stencil/vitest vitest

Usage

In your Vitest config, set the environment to stencil:

// vitest.config.ts
import { defineVitestConfig } from '@stencil/vitest/config';

export default defineVitestConfig({
  stencilConfig: './stencil.config.ts',
  test: {
    include: ['src/**/*.spec.{ts,tsx}'],
    environment: 'stencil',
  },
});

Per-File Environment

You can also set the environment on a per-file basis using a comment directive at the top of your test file:

// @vitest-environment stencil
import { render, h } from '@stencil/vitest';

describe('my-component', () => {
  // ...
});

This is useful when you have a mix of test types and only some need the Stencil environment.

Environment Options

You can configure the underlying DOM implementation using environmentOptions:

export default defineVitestConfig({
  stencilConfig: './stencil.config.ts',
  test: {
    environment: 'stencil',
    environmentOptions: {
      stencil: {
        // Choose your DOM implementation:
        // 'mock-doc' (default) - Stencil's built-in mock DOM
        // 'jsdom' - Full jsdom implementation (requires jsdom package)
        // 'happy-dom' - Fast happy-dom implementation (requires happy-dom package)
        domEnvironment: 'mock-doc',
      },
    },
  },
});

Documentation

For full documentation, including testing APIs, matchers, and examples, see the @stencil/vitest README.

License

MIT

版本列表
1.14.0 2026-07-14
1.13.3 2026-06-23
1.13.2 2026-06-15
1.13.1 2026-06-15
1.13.0 2026-06-13
1.12.1 2026-05-26
1.12.0 2026-05-24
1.11.6 2026-04-22
1.11.5 2026-04-21
1.11.4 2026-04-19
1.11.3 2026-04-15
1.11.2 2026-04-15
1.11.1 2026-04-10
1.11.0 2026-04-10
1.10.0 2026-04-01
1.9.3 2026-03-27
1.9.2 2026-03-26
1.9.1 2026-03-25
1.9.0 2026-03-24
1.8.3 2026-03-19
1.8.2 2026-03-19
1.8.1 2026-03-19
1.8.0 2026-03-17
1.7.2 2026-03-17
1.7.1 2026-03-13
1.7.0 2026-03-13
1.6.2 2026-03-12
1.6.1 2026-03-12
1.6.0 2026-03-12
1.5.0 2026-03-11
1.4.0 2026-03-10
1.3.0 2026-03-10
1.2.0 2026-03-10
1.1.21 2026-02-17
1.1.20 2026-02-16
1.1.19 2026-02-16
1.1.18 2026-02-16
1.1.17 2026-02-15
1.1.16 2026-02-15
1.1.15 2026-02-15
1.1.14 2026-02-13
1.1.13 2026-02-13
1.1.12 2026-02-13
1.1.11 2026-02-13
1.1.10 2026-02-13
1.1.9 2026-02-10
1.1.8 2026-02-09
1.1.7 2026-02-06
1.1.6 2026-02-06
1.1.5 2026-01-22
1.1.4 2026-01-22
1.1.3 2026-01-22
1.1.2 2026-01-20
1.1.1 2026-01-17
1.1.0 2026-01-13
1.0.0 2026-01-10
0.1.3 2026-01-09
0.1.2 2026-01-09
0.1.1 2026-01-09
0.1.0 2025-12-23