Skip to content

feat: add generate command #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 28, 2025
Merged

feat: add generate command #410

merged 14 commits into from
Mar 28, 2025

Conversation

rmarescu
Copy link
Member

@rmarescu rmarescu commented Mar 27, 2025

Note

Experimental feature

Follow-up on #407

New command npx shortest generate

Generates shortest/functional.test.ts test file using the test plans from test-plan.json file.

Samples: https://gist.github.com/rmarescu/fb1ac56d2ae048d2d16a9b8d2f6ed356

Copy link

vercel bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
shortest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 28, 2025 9:46pm

@rmarescu rmarescu marked this pull request as ready for review March 28, 2025 21:53

const statementArgs: any[] = [t.stringLiteral(plan.steps[0])];

if (plan.options?.requiresAuth) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple implementation to support tests that require authentication. The ENVs can be supplied during the initial setup (that will be interactive).

Comment on lines +62 to +63
const formattedCode = await formatCode(rawFileContent, this.rootDir);
const lintedCode = await lintCode(formattedCode, this.rootDir);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best effort to ensure the test file matches local format and linting rules.

const lintedCode = await lintCode(formattedCode, this.rootDir);

try {
await fs.mkdir(SHORTEST_DIR_PATH, { recursive: true });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new folder shortest within the project root. It is gitignored, so it can be added to the repo.

}).code;
}

private async getTestPlans(): Promise<TestPlan[]> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the MVP, no check has been added to ensure the plan is the current version, the current branch/commit match, etc.

@rmarescu rmarescu merged commit 6d7342c into main Mar 28, 2025
6 checks passed
@rmarescu rmarescu deleted the rmarescu/generate branch March 28, 2025 21:54
@github-project-automation github-project-automation bot moved this to Done in Shortest Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant