Skip to content

Commit ab27ab1

Browse files
committed
feat: setup vitest browser mode base configurations
1 parent ffc2ab5 commit ab27ab1

File tree

14 files changed

+669
-995
lines changed

14 files changed

+669
-995
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
node-version-file: .nvmrc
2424
- name: Install dependencies
2525
run: pnpm install
26+
- name: Install Playwright Browsers
27+
run: pnpx playwright install --with-deps
2628
- name: Lint
2729
run: pnpm --filter="...[origin/${{ github.base_ref }}]" "/lint:*/"
2830
- name: Test

.github/workflows/coverage.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
node-version-file: .nvmrc
2323
- name: Install dependencies
2424
run: pnpm install
25+
- name: Install Playwright Browsers
26+
run: pnpx playwright install --with-deps
2527
- name: Run tests
2628
run: pnpm run test --coverage
2729
- name: Upload code coverage

.templates/component/global.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

.templates/component/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"typecheck": "tsc",
2121
"prepack": "pnpm run build"
2222
},
23+
"dependencies": {
24+
"clsx": "^2.1.1"
25+
},
2326
"devDependencies": {
2427
"@storybook/addon-essentials": "catalog:",
2528
"@storybook/addon-interactions": "catalog:",
@@ -28,16 +31,16 @@
2831
"@storybook/react": "catalog:",
2932
"@storybook/react-vite": "catalog:",
3033
"@storybook/test": "catalog:",
31-
"@testing-library/jest-dom": "catalog:",
32-
"@testing-library/react": "catalog:",
3334
"@types/react": "^18.3.12",
34-
"happy-dom": "catalog:",
35+
"@vanilla-extract/css": "catalog:",
36+
"playwright": "catalog:",
3537
"react": "^18.3.1",
3638
"react-dom": "^18.3.1",
3739
"storybook": "catalog:",
3840
"tsup": "catalog:",
3941
"typescript": "catalog:",
40-
"vitest": "catalog:"
42+
"vitest": "catalog:",
43+
"vitest-browser-react": "catalog:"
4144
},
4245
"peerDependencies": {
4346
"react": ">= 18",
@@ -60,6 +63,6 @@
6063
"./styles.css": "./dist/index.css"
6164
}
6265
},
63-
"sideEffects": false,
66+
"sideEffects": ["*.css"],
6467
"private": true
6568
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { style } from '@vanilla-extract/css';
2+
3+
export const root = style({
4+
border: '1px solid black',
5+
});
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import { Component } from './Component';
33

4-
const meta = {
5-
component: Component,
4+
export default {
65
title: 'Components/Component',
6+
component: Component,
77
parameters: {
88
layout: 'centered',
99
},
1010
} satisfies Meta<typeof Component>;
11-
export default meta;
1211

13-
type Story = StoryObj<typeof meta>;
12+
type Story = StoryObj<typeof Component>;
1413

15-
export const Basic: Story = {};
14+
export const Basic: Story = {
15+
args: {
16+
children: 'children',
17+
},
18+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expect, test } from 'vitest';
2+
import { render } from 'vitest-browser-react';
3+
import { Component } from './Component';
4+
5+
test('should render component.', async () => {
6+
const screen = render(<Component>children</Component>);
7+
8+
await expect.element(screen.getByText('children')).toBeInTheDocument();
9+
});
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export function Component() {
2-
return <div>Component</div>;
1+
import { clsx as cx } from 'clsx';
2+
import type { ComponentProps } from 'react';
3+
import * as styles from './Component.css';
4+
5+
export function Component({ className, ...props }: ComponentProps<'div'>) {
6+
return <div className={cx(styles.root, className)} {...props} />;
37
}
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
import { defineConfig } from 'tsup';
2-
3-
export default defineConfig({
4-
entry: ['src/index.ts'],
5-
clean: true,
6-
dts: true,
7-
format: ['esm', 'cjs'],
8-
});
1+
export { default } from '../../tsup.config';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from '../../vite.config';

0 commit comments

Comments
 (0)