Skip to content

Commit

Permalink
NordstarProvider: Add super simple test(s).
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphsps committed Nov 5, 2023
1 parent 66b3ea0 commit 778d078
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 21 deletions.
7 changes: 6 additions & 1 deletion .vitest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
});
15 changes: 15 additions & 0 deletions packages/core/nordstar/src/nordstar-provider.test.tsx
Original file line number Diff line number Diff line change
@@ -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(
<NordstarProvider>
<div>Hello, world!</div>
</NordstarProvider>
);
expect(getByText('Hello, world!')).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"access": "public"
},
"scripts": {
"build": "tsup src --dts",
"build": "storybook build",
"dev": "storybook dev -p 3001",
"start": ""
},
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
27 changes: 12 additions & 15 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -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"]
}
}
}
13 changes: 10 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -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()],
Expand All @@ -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,
Expand Down

0 comments on commit 778d078

Please sign in to comment.