diff --git a/.vitest/setup.ts b/.vitest/setup.ts index 413ec6d3..cad82355 100644 --- a/.vitest/setup.ts +++ b/.vitest/setup.ts @@ -2,6 +2,11 @@ import 'next'; import * as matchers from '@testing-library/jest-dom/matchers'; -import { expect } from 'vitest'; +import { expect, vi } from 'vitest'; expect.extend(matchers); + +// Mock the `server-only` module as it doesn't work with vitest. +vi.mock('server-only', () => { + return {}; +}); diff --git a/packages/core/nordstar/src/nordstar-provider.test.tsx b/packages/core/nordstar/src/nordstar-provider.test.tsx new file mode 100644 index 00000000..8bf01a55 --- /dev/null +++ b/packages/core/nordstar/src/nordstar-provider.test.tsx @@ -0,0 +1,15 @@ +import { describe, expect, it } from 'vitest'; + +import { render } from '@testing-library/react'; +import { NordstarProvider } from './nordstar-provider'; + +describe('NordstarProvider', () => { + it('renders its children', () => { + const { getByText } = render( + +
Hello, world!
+
+ ); + expect(getByText('Hello, world!')).toBeInTheDocument(); + }); +}); diff --git a/packages/storybook/package.json b/packages/storybook/package.json index c4cfa6c6..f492ec07 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -39,7 +39,7 @@ "access": "public" }, "scripts": { - "build": "tsup src --dts", + "build": "storybook build", "dev": "storybook dev -p 3001", "start": "" }, diff --git a/tsconfig.json b/tsconfig.json index 83cccaa2..2e4c782a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,8 @@ "sourceMap": true, "strict": true, "strictNullChecks": true, - "target": "ESNext" + "target": "ESNext", + "types": ["vitest/globals", "@testing-library/jest-dom"] }, "include": ["packages"], "exclude": ["**/node_modules", "**/dist", "**/.turbo"] diff --git a/turbo.json b/turbo.json index b882227a..7ea816cf 100644 --- a/turbo.json +++ b/turbo.json @@ -1,33 +1,30 @@ { "$schema": "https://turbo.build/schema.json", - "baseBranch": "origin/master", "globalDependencies": ["tsconfig.json"], "pipeline": { "build": { "dependsOn": ["^build"], - "outputs": [".next/**", "dist/**", "lib/**"] + "outputs": ["**/.next/**", "!**/.next/cache/**", "**/dist/**", "**/storybook-static/**"] }, - "typecheck": { + "clean": { "cache": false, - "dependsOn": ["^typecheck"] + "outputs": [] }, + "dev": { + "cache": false, + "persistent": true + }, + "lint": {}, "start": { - "dependsOn": ["^build"], - "outputs": [] + "dependsOn": ["build"] }, "test": { "dependsOn": ["build"], - "outputs": [] + "outputs": ["coverage/**"] }, - "clean": { + "typecheck": { "cache": false, - "outputs": [] - }, - "lint": { - "outputs": [] - }, - "dev": { - "cache": false + "dependsOn": ["^typecheck"] } } } diff --git a/vitest.config.ts b/vitest.config.ts index a23c628e..2af91b76 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vitest/config'; import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vitest/config'; export default defineConfig({ plugins: [react()], @@ -9,8 +9,15 @@ export default defineConfig({ test: { coverage: { all: true, - include: ['src/**/*.{js,ts,jsx,tsx}'], - exclude: ['**/*.d.ts', '**/*.test.{js,ts,jsx,tsx}', '**/*.spec.{js,ts,jsx,tsx}'] + exclude: [ + '**/*.d.ts', + '**/*.test.{js,ts,jsx,tsx}', + '**/*.stories.{js,ts,jsx,tsx}', + '**/src/app/{page,layout}.{js,ts,jsx,tsx}', + '**/packages/**/src/index.{js,ts,jsx,tsx}' + ], + include: ['**/src/**/*.{js,ts,jsx,tsx}'], + provider: 'v8' }, environment: 'jsdom', globals: true,