Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(web-components): add vitest local coverage reports #6726

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"upgrade:dependencies:examples": "npm-check-updates -u --dep dev,peer,prod --color --target minor --packageFile 'scripts/example-gallery-builder/update-example/**/package.json'",
"upgrade:automatic": "run-s -s 'upgrade:dependencies:*'",
"upgrade:carbon": "npm-check-updates -u --dep dev,peer,prod --packageFile '{package.json,{config/**,packages/**}/package.json}' --filter '/carbon/' --target minor",
"visual-snapshot": "cd packages/core && yarn percy storybook storybook-static"
"visual-snapshot": "cd packages/core && yarn percy storybook storybook-static",
"wc-coverage": "cd packages/ibm-products-web-components && yarn coverage"
},
"devDependencies": {
"@babel/core": "^7.23.9",
Expand Down
11 changes: 6 additions & 5 deletions packages/ibm-products-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"preview": "vite preview",
"storybook": "storybook dev -p 3000",
"test": "vitest run",
"test:ui": "vitest --ui",
"wca": "web-component-analyzer analyze src --outFile custom-elements.json"
"wca": "web-component-analyzer analyze src --outFile custom-elements.json",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@carbon/ibm-products-styles": "^2.54.0",
Expand All @@ -73,9 +73,10 @@
"@storybook/web-components": "^8.4.5",
"@storybook/web-components-vite": "^8.4.5",
"@types/jest": "^29.5.13",
"@vitest/browser": "latest",
"@vitest/ui": "latest",
"@vitest/browser": "^3.0.1",
"@vitest/coverage-v8": "^3.0.1",
"autoprefixer": "^10.4.20",
"c8": "^10.1.3",
"cssnano": "^7.0.6",
"eslint": "^8.56.0",
"eslint-config-carbon": "3.18.0",
Expand All @@ -92,7 +93,7 @@
"tslib": "^2.8.1",
"typescript": "^5.5.3",
"vite": "^6.0.3",
"vitest": "^2.1.2",
"vitest": "^3.0.1",
"web-component-analyzer": "2.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
vi.mock('@carbon/icons/lib/close/20', () => vi.fn().mockReturnValue({}));
import { describe, expect, it, vi } from 'vitest';
import { render, html } from 'lit';
import { SIDE_PANEL_PLACEMENT, SIDE_PANEL_SIZE } from './defs';

const defaultProps = {
animateTitle: true,
Expand All @@ -16,10 +17,10 @@ const defaultProps = {
selectorInitialFocus: '',
label: '',
open: true,
placement: 'right',
placement: SIDE_PANEL_PLACEMENT.RIGHT,
preventCloseOnClickOutside: false,
selectorPageContent: '',
size: 'md',
size: SIDE_PANEL_SIZE.MEDIUM,
title: 'Side panel title',
};

Expand Down
8 changes: 7 additions & 1 deletion packages/ibm-products-web-components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
plugins: [litStyleLoader(), litTemplateLoader()],
test: {
environment: 'happy-dom',
include: ['./src/**/*.{test,spec}.{js,ts}'],
include: ['src/**/*.test.ts'],
exclude: [...configDefaults.exclude],
// Lit recommends using browser environment for testing
// https://lit.dev/docs/tools/testing/#testing-in-the-browser
Expand All @@ -22,5 +22,11 @@ export default defineConfig({
headless: true,
name: 'chromium',
},
coverage: {
provider: 'v8',
include: ['src/**/*'],
exclude: ['src/**/*.stories.{js,ts}'],
reporter: ['text', 'html'],
},
},
});
Loading
Loading