Add CLI tests and run the build in CI - #25
Merged
Merged
Conversation
The library was covered, but nothing exercised the CLI itself: option parsing and validation, the stdout/stderr split that scripts and GITHUB_ENV rely on, exit codes, or the package.json lookup relative to dist/. The new tests spawn node dist/cli.js in temporary projects and assert exact output, so the flags and formats are pinned down as a contract. A vitest globalSetup builds dist before each run, so `yarn test` never tests a stale binary. The config uses the .mts extension because Vite loads a .ts config as CommonJS in a package without "type": "module".
`yarn tsc` type-checks with noEmit and covers the tests, but declaration emit is only exercised by the build, so an emit-only error would have surfaced first during a release. CI now builds explicitly between the type-check and the tests. The test setup rebuilds dist as well; the separate step makes the intent visible in the workflow and does not depend on how the tests are wired.
Contributor
|
🎉 Released in v0.7.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nothing exercised the CLI layer so far: option parsing and validation, the stdout/stderr split, exit codes, and the
package.jsonlookup relative todist/were only checked by hand. This adds black-box tests that spawnnode dist/cli.jsin temporary projects and assert exact output, so the flags, formats and exit codes are pinned down as a contract ahead of 1.0.--dry-run,--version-name,--version-code,--reserve-builds,--project-dir, the missing-file warning and failure), reads (each--print*flag,--format,--configuration, a relative--gradle-path), option validation (every rejected combination with its exact message), and--version/--help.globalSetupbuildsdistbefore each run, soyarn testnever tests a stale binary. The whole suite still runs in about 1.5 s. The config isvitest.config.mtsbecause Vite loads a.tsconfig as CommonJS in a package without"type": "module"and warns about it.yarn buildbetweenyarn tscandyarn test. The type-check is noEmit, so declaration emit was only exercised at release time. The test setup rebuilds anyway; the explicit step documents the intent and does not depend on how the tests are wired.