feat: add frontend unit test framework (#6426)

This commit is contained in:
Joel
2024-07-18 17:35:10 +08:00
committed by GitHub
parent afe95fa780
commit 4ae4895ebe
8 changed files with 2439 additions and 21 deletions

View File

@@ -74,6 +74,25 @@ npm run start --port=3001 --host=0.0.0.0
If your IDE is VSCode, rename `web/.vscode/settings.example.json` to `web/.vscode/settings.json` for lint code setting.
## Test
We start to use [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) for Unit Testing.
You can create a test file with a suffix of `.spec` beside the file that to be tested. For example, if you want to test a file named `util.ts`. The test file name should be `util.spec.ts`.
Run test:
```bash
npm run test
```
If you are not familiar with writing tests, here is some code to refer to:
* [classnames.spec.ts](./utils/classnames.spec.ts)
* [index.spec.tsx](./app/components/base/button/index.spec.tsx)
## Documentation
Visit <https://docs.dify.ai/getting-started/readme> to view the full documentation.