Skip to content

Commit

Permalink
feat(core): Setup tests with [vitest](https://vitest.dev/)
Browse files Browse the repository at this point in the history
  • Loading branch information
wootsbot committed Aug 11, 2023
1 parent 7ee7c13 commit e7f0ef8
Show file tree
Hide file tree
Showing 7 changed files with 1,461 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-parents-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'x-boilerplate': minor
---

Setup tests with [vitest](https://vitest.dev/)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Many of this boilerplate features are based on the philosophy of being optional.
- [x] ~Integrate resend~
- [x] ~Integrate @react-email~
- [x] ~Internationalization with react-i18next (SSG)~
- [x] ~Setup tests with [vitest](https://vitest.dev/)~
- [x] Setup test with [vitest](https://vitest.dev/) and [playwright](https://playwright.dev/)
- [x] Added test all components
- [x] More examples with resend and @react-email
- [x] Integrate ORM prisma
- [x] Integrate supabase
Expand Down
23 changes: 23 additions & 0 deletions components/container/Container.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, test } from 'vitest';

import Container from './Container';

describe('<Container />', () => {
test('must render correctly', () => {
const { container } = render(
<Container>
<h1>Container</h1>
</Container>,
);

expect(
screen.getByRole('heading', {
name: /container/i,
}),
).toBeDefined();
expect(screen.getByRole('heading')).toBeDefined();

expect(container).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions components/container/__snapshots__/Container.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`<Container /> > must render correctly 1`] = `
<div>
<div
class="_root_eec566"
>
<h1>
Container
</h1>
</div>
</div>
`;
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "vitest",
"test:ui": "vitest --ui",
"test:coverage": "vitest run --coverage",
"prettier:format": "prettier --config .prettierrc \"./**/*.+(js|ts)\" --write",
"prettier": "prettier --config .prettierrc \"./**/*.+(js|ts)\" --check",
"changeset": "changeset",
Expand Down Expand Up @@ -57,19 +60,25 @@
"@changesets/types": "5.2.1",
"@commitlint/cli": "17.6.7",
"@commitlint/config-conventional": "17.6.7",
"@testing-library/react": "14.0.0",
"@types/node": "20.4.5",
"@types/react": "18.2.17",
"@types/react-dom": "18.2.7",
"@vitejs/plugin-react": "4.0.4",
"@vitest/coverage-v8": "0.34.1",
"@vitest/ui": "0.34.1",
"eslint": "8.45.0",
"eslint-config-next": "13.4.12",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-simple-import-sort": "10.0.0",
"husky": "8.0.3",
"jsdom": "22.1.0",
"lint-staged": "13.2.3",
"msw": "1.2.3",
"prettier": "3.0.0",
"typescript": "5.1.6"
"typescript": "5.1.6",
"vitest": "0.34.1"
},
"msw": {
"workerDirectory": "public"
Expand Down
Loading

1 comment on commit e7f0ef8

@vercel
Copy link

@vercel vercel bot commented on e7f0ef8 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.