Template for creating Neovici public web components using pionjs and lit-html.
npm installnpm run lint- Run ESLint and TypeScript type checkingnpm run build- Build TypeScript to dist/npm run test- Run all tests (unit + storybook)npm run test:unit- Run unit tests only (fast, jsdom)npm run test:storybook- Run storybook interaction tests only (browser)npm run test:watch- Run tests in watch modenpm run storybook:start- Start Storybook development servernpm run storybook:build- Build static Storybook
Import the component:
import '@neovici/cosmoz-component';Use in HTML:
<cosmoz-component greeting="Hi"></cosmoz-component>- Clone the repository
- Run
npm install - Start development with
npm run storybook:start - Make changes and verify with tests
This template uses Vitest with two test projects:
Fast tests that run in jsdom. Use for testing:
- Utility functions
- Pure logic
- Data transformations
Note: Unit tests cannot import Pion/Lit components or use renderHook from @neovici/testing due to ESM resolution issues in jsdom. For testing hooks and components, use Storybook interaction tests instead.
// test/example.test.ts
import { describe, expect, it } from 'vitest';
import { myFunction } from '../src/utils';
describe('myFunction', () => {
it('does something', () => {
expect(myFunction()).toBe(expected);
});
});Browser-based tests using Playwright. Use for testing:
- Component rendering
- User interactions
- Visual behavior
Tests are written as play functions in story files.
Never import from 'vitest' in story files:
import { expect } from 'vitest'; // Crashes deployed StorybookUse 'storybook/test' instead:
import { expect } from 'storybook/test'; // Works everywhereVitest's expect requires an active test context and crashes when stories run in the deployed Storybook UI.
This package uses Semantic Release for automated versioning and publishing. Commits are analyzed and releases are created automatically based on Conventional Commits.