vitest-environment-stencil
Custom Vitest environment for Stencil component testing
Last updated 10 days ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install vitest-environment-stencil 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.10.0                                ...           latest (10 days ago)

46 Versions

  • 1.10.0                                ...           10 days ago
  • 1.9.3                                ...           15 days ago
  • 1.9.2                                ...           17 days ago
  • 1.9.1                                ...           17 days ago
  • 1.9.0                                ...           18 days ago
  • 1.8.3                                ...           23 days ago
  • 1.8.2                                ...           23 days ago
  • 1.8.1                                ...           23 days ago
  • 1.8.0                                ...           25 days ago
  • 1.7.2                                ...           25 days ago
  • 1.7.1                                ...           a month ago
  • 1.7.0                                ...           a month ago
  • 1.6.2                                ...           a month ago
  • 1.6.1                                ...           a month ago
  • 1.6.0                                ...           a month ago
  • 1.5.0                                ...           a month ago
  • 1.4.0                                ...           a month ago
  • 1.3.0                                ...           a month ago
  • 1.2.0                                ...           a month ago
  • 1.1.21                                ...           2 months ago
  • 1.1.20                                ...           2 months ago
  • 1.1.19                                ...           2 months ago
  • 1.1.18                                ...           2 months ago
  • 1.1.17                                ...           2 months ago
  • 1.1.16                                ...           2 months ago
  • 1.1.15                                ...           2 months ago
  • 1.1.14                                ...           2 months ago
  • 1.1.13                                ...           2 months ago
  • 1.1.12                                ...           2 months ago
  • 1.1.11                                ...           2 months ago
  • 1.1.10                                ...           2 months ago
  • 1.1.9                                ...           2 months ago
  • 1.1.8                                ...           2 months ago
  • 1.1.7                                ...           2 months ago
  • 1.1.6                                ...           2 months ago
  • 1.1.5                                ...           3 months ago
  • 1.1.4                                ...           3 months ago
  • 1.1.3                                ...           3 months ago
  • 1.1.2                                ...           3 months ago
  • 1.1.1                                ...           3 months ago
  • 1.1.0                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
  • 0.1.3                                ...           3 months ago
  • 0.1.2                                ...           3 months ago
  • 0.1.1                                ...           3 months ago
  • 0.1.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |