Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rmarescu
Copy link
Member

@rmarescu rmarescu commented Feb 23, 2025

  • Make config.testPattern optional, default to **/*.test.ts
  • Improve test runner error handling
  • Improve CLI help output formatting and organization

Why

  • One step closer towards zero-config
  • Reduce complexity and technical debt around error handling and default values

CleanShot 2025-02-22 at 16 26 13@2x

@rmarescu rmarescu self-assigned this Feb 23, 2025
@vercel
Copy link

vercel bot commented Feb 23, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
shortest ⬜️ Ignored (Inspect) Visit Preview Feb 23, 2025 0:36am

@rmarescu rmarescu added this to the v0.4.4 milestone Feb 23, 2025
@rmarescu rmarescu marked this pull request as ready for review February 23, 2025 00:40
const runner = new TestRunner(process.cwd(), config);
await runner.initialize();
const success = await runner.runTests(testPattern);
const success = await runner.execute(config.testPattern);
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 name better represents what the function does (at the time of calling, is not known yet if there are any tests to be executed yet).

Comment on lines -73 to -82
if (files.length === 0) {
this.reporter.error(
"Test Discovery",
`No test files found matching: ${testPattern}`,
);
this.log.error("No test files found matching", {
pattern: testPattern,
});
process.exit(1);
}
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 duplicated started on line 375 below.


private async findTestFiles(pattern?: string): Promise<string[]> {
this.log.trace("Finding test files", { pattern });
const testPattern = pattern || this.config.testPattern || "**/*.test.ts";
Copy link
Member Author

Choose a reason for hiding this comment

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

Config should be the source of truth of all default values, in conjuction with Zod validation.

this.browserManager = new BrowserManager(this.config);
}

private async findTestFiles(pattern?: string): Promise<string[]> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Once the default value assignment and duplicated logic are removed, there isn't much value having this function.

describe("Config parsing", () => {
let baseConfig: ShortestConfig;

beforeEach(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved below (not used by with minimal config test)

@rmarescu rmarescu merged commit 96836b6 into main Feb 23, 2025
6 checks passed
@rmarescu rmarescu deleted the rmarescu/config-test-pattern-optional branch February 23, 2025 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants