An open API service indexing awesome lists of open source software.

https://github.com/jellydn/auto-testgen-nodejs

How to use AI to generate unit tests
https://github.com/jellydn/auto-testgen-nodejs

ai drizzle drizzle-orm nodejs pythagora turso

Last synced: 6 months ago
JSON representation

How to use AI to generate unit tests

Awesome Lists containing this project

README

          

Welcome to auto-testgen-nodejs 👋



How to use AI to generate unit tests

Version

License: MIT

[![IT Man - AI-Powered Unit Testing in 2023 [Vietnamese]](https://i.ytimg.com/vi/1YvrwOeZk5w/hqdefault.jpg)](https://www.youtube.com/watch?v=1YvrwOeZk5w)

## Demo

![https://gyazo.com/5563528f5b41d126257a573f84631097.gif](https://gyazo.com/5563528f5b41d126257a573f84631097.gif)

## Usage

```sh
pnpm install
```

### Setup

1. First, add the [Pythagora](https://github.com/Pythagora-io/pythagora) API key to your environment using the command:

```sh
npx pythagora --config --pythagora-api-key YOUR_API_KEY
```

This command will store your Pythagora API key in a config file which will be used for generating your tests.

### Generating Unit Tests

2. To generate unit tests for a specific function in your Node.js application, use the following command:

```sh
npx pythagora --unit-tests --func divide --path src/math.ts
```

In the above command, replace `divide` with the name of the function you want to test and `src/math.ts` with the path to the file that contains the function. The tool will automatically create a unit test for the specified function.

_Note_: Pythagora support [Typescript](https://github.com/Pythagora-io/pythagora/issues/10) file since version 0.0.36

## Plan/Todo

- [ ] Add example/guide with [integration test](https://github.com/Pythagora-io/pythagora/blob/main/src/docs/integration/README.md)
- [ ] Add example with GraphQL ([Grafbase - Instant GraphQL APIs for your data](https://grafbase.com/))
- [ ] Add example with DB ([DrizzleORM - next gen TypeScript ORM](https://orm.drizzle.team/))

## Author

- Website: https://productsway.com/
- Twitter: [@jellydn](https://twitter.com/jellydn)
- Github: [@jellydn](https://github.com/jellydn)

## Show your support

[![kofi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/dunghd)
[![paypal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/dunghd)
[![buymeacoffee](https://img.shields.io/badge/Buy_Me_A_Coffee-FFDD00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/dunghd)

Give a ⭐️ if this project helped you!