fix: Web core test and CI workflow fixes#1000
fix: Web core test and CI workflow fixes#1000jacobsimionato wants to merge 5 commits intogoogle:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates @a2ui/web_core to version 0.9.0, refines the test execution command to target specific test files, and replaces type-only variable declarations in tests with runtime assertions to satisfy linting requirements. The review feedback suggests using the void operator instead of assert.strictEqual for variables intended only for compile-time type validation, as this avoids unnecessary runtime checks while still silencing unused variable warnings.
| // This happens when `mockApi: ComponentApi`, but doesn't when | ||
| // `mockApi {} satisfies ComponentApi`! | ||
| const inferredIsAny: IsAny<InferredType> = false; | ||
| assert.strictEqual(inferredIsAny, false); |
There was a problem hiding this comment.
While using assert.strictEqual works to silence the 'no-unused-vars' lint error, it adds a runtime assertion for what is a compile-time type check. The purpose of inferredIsAny is to fail at compile time if the type is incorrect, not to be asserted at runtime.
A more idiomatic and clearer way to mark a variable as intentionally used for its type-level effects is to use the void operator. This signals that you are using the variable for its compile-time check and intentionally discarding its value, without adding a runtime assertion.
| assert.strictEqual(inferredIsAny, false); | |
| void inferredIsAny; |
| // typesMatchExact only accepts "true" if `TypesAreEquivalent` | ||
| const typesMatchExact: TypesAreEquivalent<ExpectedType, InferredType> = | ||
| true; | ||
| assert.strictEqual(typesMatchExact, true); |
There was a problem hiding this comment.
Similar to the other type-level check, using assert.strictEqual here adds a runtime assertion for a compile-time check.
To make the intent clearer and avoid a redundant runtime check, you can use the void operator to mark typesMatchExact as intentionally used for its type-level effects.
| assert.strictEqual(typesMatchExact, true); | |
| void typesMatchExact; |
Description
This PR addresses multiple issues preventing the
web_coretests from running successfully locally and in CI.Description of Changes
runs-on: ubuntu-latestto thelintjob in.github/workflows/web_build_and_test.ymland standardized thepathsglob pattern.testscript inrenderers/web_core/package.jsonto use a glob pattern (node --test "dist/**/*.test.js") instead of pointing to the directory, resolvingMODULE_NOT_FOUNDerrors locally and in CI.@typescript-eslint/no-unused-varslinting errors inrenderers/web_core/src/v0_9/catalog/types.test.tsby asserting the unused type-level variables at runtime.Rationale
runs-onproperty in thelintjob caused GitHub Actions to mark the entireweb_build_and_test.ymlworkflow as invalid, preventing both tests and linting from running.node --test) can fail with module resolution errors when pointed directly at a directory (dist) in a"type": "module"project. Using a specific glob pattern bypasses this issue.npm run lintstep to fail.Testing/Running Instructions
renderers/web_coredirectory:cd renderers/web_corenpm run test(should pass successfully).npm run lint(should pass with no errors).Web coreworkflow now successfully triggers and completes.Pre-launch Checklist