sweepai-dev / fern-typescript

Generate TypeScript models, clients, and server interfaces from your API definition.
MIT License
0 stars 0 forks source link

Sweep: Scaffold tests in generated SDK #1

Open wwzeng1 opened 1 year ago

wwzeng1 commented 1 year ago

We recently introduced simple test scaffolding in fern-python. We should do something similar here, potentially with jest.

Previous PR:

This adds pytest to the list of dev dependencies, as well as creates a tests/ directory with a simple no-op test.

The generated test includes the syntax required for skipping tests (via @pytest.mark.skip) to demonstrate the pytest import. We also include a link to the pytest docs for the user to learn more.

sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/sweepai-dev/fern-typescript/pull/10.

💎 Sweep Pro: I used GPT-4 to create this ticket. You have 55 GPT-4 tickets left.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/sweepai-dev/fern-typescript/blob/7c85a6f37c640317e73fb904968126aa816e43c5/packages/generators/sdk/cli/src/__test__/generate.test.ts#L182-L359 https://github.com/sweepai-dev/fern-typescript/blob/7c85a6f37c640317e73fb904968126aa816e43c5/packages/generators/sdk/cli/src/__test__/fixtures/fern/no-zurg-no-throwing/sdk-no-zurg-no-throwing.shot#L1-L64 https://github.com/sweepai-dev/fern-typescript/blob/7c85a6f37c640317e73fb904968126aa816e43c5/jest.config.ts#L1-L74 https://github.com/sweepai-dev/fern-typescript/blob/7c85a6f37c640317e73fb904968126aa816e43c5/packages/generators/sdk/cli/src/__test__/generate.test.ts#L1-L61 https://github.com/sweepai-dev/fern-typescript/blob/7c85a6f37c640317e73fb904968126aa816e43c5/packages/generators/sdk/cli/src/__test__/fixtures/fern/variables/sdk-variables.shot#L1-L64

I also found the following external resources that might be helpful:

Summaries of links found in the content:

https://github.com/fern-api/fern-python/pull/296

The page is a pull request on GitHub for the fern-python repository. The pull request (#296) adds pytest to the list of dev dependencies and creates a tests/ directory with a simple no-op test. The generated test includes the syntax required for skipping tests using @pytest.mark.skip. The pull request also includes a link to the pytest documentation for further learning. There are also comments on the pull request, but they are not relevant to the problem.


Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
packages/generators/sdk/cli/src/SdkGeneratorCli.ts Modify the SdkGeneratorCli class to include a method for generating a simple no-op test. This method should create a new test file in the tests directory of the generated SDK. The test file should include a simple test that is skipped by default, and a link to Jest's documentation.
package.json Add Jest as a dev dependency. This can be done by adding "jest": "^latest_version" to the "devDependencies" section of the file.
packages/generators/sdk/cli/src/__test__/fixtures/fern/no-zurg-no-throwing/tests/noop.test.ts Create a new test file in the tests directory of the generated SDK. This file should include a simple test that is skipped by default, and a link to Jest's documentation.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add test scaffolding to generated SDK sweep/add-test-scaffolding

Description

This PR adds test scaffolding to the generated SDK. It includes the following changes:

  • Added Jest as a dev dependency in the package.json file.
  • Created a tests directory in the generated SDK.
  • Generated a simple no-op test as a starting point for users.
  • Included syntax for skipping tests using Jest's skip method in the generated test file.
  • Added a link to Jest's documentation in the generated test file.

Summary

  • Modified the SdkGeneratorCli class in the packages/generators/sdk/cli/src/SdkGeneratorCli.ts file to include a method for generating a simple no-op test.
  • Added Jest as a dev dependency in the package.json file.
  • Created a new test file in the tests directory of the generated SDK.
  • The generated test file includes a simple test that is skipped by default, and a link to Jest's documentation for further learning.

Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord

kevinlu1248 commented 1 year ago

sweep: retry

kevinlu1248 commented 1 year ago

sweep: retry

kevinlu1248 commented 1 year ago

sweep: retry