2022-03-16 00:47:42 +03:00
# Component testing with Playwright and Vue3
## Recommended IDE Setup
[VSCode ](https://code.visualstudio.com/ ) + [Volar ](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar ) (and disable Vetur) + [TypeScript Vue Plugin (Volar) ](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin ) + [Playwright Test for VSCode ](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright ).
## Project Setup
```sh
npm i
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Test project
Run tests from your VS Code, or execute
```sh
npm run test
```
## How to add component tests using Playwright
- npm init vue@latest was used to create a default project.
```sh
npm init vue@latest
```
2022-05-02 19:00:51 +03:00
- Install Playwright Test with component testing as dev dependencies.
2022-03-16 00:47:42 +03:00
```sh
npm i --save-dev @playwright/test @playwright/experimental -ct-vue
```
2022-05-02 19:00:51 +03:00
- [playwright/index.html ](playwright/index.html ) file was added that defines theming for the components through importing [playwright/index.js ](playwright/index.js ) .
- [playwright.config.ts ](playwright.config.ts ) was added that executes `npm run dev` before running tests if it is not already running.
2022-03-16 00:47:42 +03:00
- A bunch of `.spec.ts` and `.spec.tsx` files were added to `src` that demonstrate Vue3 component testing with and without the use of JSX syntax.