Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobhsu/vitest
https://github.com/jacobhsu/vitest
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jacobhsu/vitest
- Owner: JacobHsu
- Created: 2024-12-12T08:39:37.000Z (24 days ago)
- Default Branch: main
- Last Pushed: 2024-12-12T09:16:45.000Z (24 days ago)
- Last Synced: 2024-12-12T09:37:15.779Z (24 days ago)
- Language: JavaScript
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# quicktest-with-vitest
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
yarn
```### Compile and Hot-Reload for Development
```sh
yarn dev
```### Compile and Minify for Production
```sh
yarn build
```### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
yarn test:unit
```### Lint with [ESLint](https://eslint.org/)
```sh
yarn lint
```## pnpm test
[mount()](https://v1.test-utils.vuejs.org/api/mount.html)
```bash
✓ src/components/__tests__/NotificationToast.test.js (6)
✓ Notification component (6)
✓ renders the correct style for error
✓ renders correct style for success
✓ renders correct style for info
✓ slides up when message is empty
✓ emits event when close button is clicked
✓ renders correct message to viewerTest Files 1 passed (1)
Tests 6 passed (6)
```### [snapshot](https://cn.vitest.dev/guide/snapshot)
```js
{{ message }}
``````bash
AssertionError: Snapshot `Notification component > renders the correct style for error 1` mismatched
- Expected - 1
+ Received + 1"
"
- ✕
+ ✕
```### Mocking
[vi.spyOn](https://vitest.dev/api/vi.html#vi-spyon)
`vi.spyOn(axios, 'get').mockResolvedValueOnce({ data: mockPost })`