Minify content tests, update dependencies#49
Conversation
WalkthroughThis PR updates the test framework's TypeScript version to 5.9.3, extends the expect API with toContain and negated assertions, renames findAndRunTests to testsRunner, adds a comprehensive test suite for minifyContents, updates Node.js engine requirement to 20+, and removes Node.js 18 from the CI matrix. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/minify/minifyContents.spec.ts (1)
4-60: Good coverage of minifyContents behavior, but some assertions are quite brittleThis suite nicely exercises the key paths: HTML minification, non‑HTML passthrough, fileType normalization (case + whitespace), and robustness to invalid HTML, all aligned with the current
minifyContentsimplementation.Two minor points you may want to consider:
- A few expectations tightly couple to the exact formatting of the minifier output (e.g.,
not.toContain('\n'), exact<div>test</div>, specific<!doctype html>casing). If the underlying minifier changes its formatting without changing semantics, these tests could start failing; relaxing to more semantic checks (e.g., presence of key substrings, or using regex) would make them less fragile.- On Line 34,
}); test('should return original content if fileType is not html', ...)on the same line is valid but a bit hard to read; splitting the secondtestonto its own line would improve clarity.local_modules/simple-test-framework/src/index.ts (1)
168-195: testsRunner is a good public entrypoint; just be aware it always terminates the processThe
testsRunnerwrapper aroundfindAndRunTestscleanly aggregates failures, prints a summary with timing, and exits with the appropriate status code. That’s ideal for a CLI, but it does mean that any consumer callingtestsRunnerprogrammatically won’t regain control afterward. If you ever need a library-style API, you might later want a variant that returns a result object instead of callingprocess.exit.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
local_modules/simple-test-framework/package-lock.jsonis excluded by!**/package-lock.jsonpackage-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
.github/workflows/dev.yml(1 hunks)local_modules/simple-test-framework/package.json(1 hunks)local_modules/simple-test-framework/src/index.d.ts(2 hunks)local_modules/simple-test-framework/src/index.ts(1 hunks)package.json(1 hunks)src/minify/minifyContents.spec.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
local_modules/simple-test-framework/src/index.d.ts (1)
local_modules/simple-test-framework/src/index.ts (2)
runTestFile(143-148)testsRunner(168-195)
src/minify/minifyContents.spec.ts (2)
src/minify/minifyContents.ts (1)
minifyContents(12-23)local_modules/simple-test-framework/src/index.ts (1)
expect(90-141)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
local_modules/simple-test-framework/package.json (1)
12-15: TypeScript devDependency bump looks consistent with repo toolingAligning this package’s TypeScript version with the root (5.9.3) keeps the build/test tooling coherent; no issues from what’s visible here, as long as the existing tsconfig still compiles cleanly under TS 5.9.x.
.github/workflows/dev.yml (1)
19-21: CI Node matrix correctly aligned with engines requirementTargeting Node 20, 22, and 24 matches the updated
"engines": { "node": ">=20.0.0" }and should keep CI focused on supported runtimes. Just ensure your dependencies are confirmed compatible with Node 24 as well, since that’s sometimes ahead of many libraries’ tested ranges.package.json (1)
61-70: Dev tooling and engines updates are coherent with the rest of the PRAdding
ts-nodeas a devDependency and bumping"engines.node"to>=20.0.0line up with your dev scripts and the updated CI matrix. From what’s here, the setup is consistent; just make surets-node@10.9.2runs clean with TypeScript 5.9.x on Node 20+ by exercising thedev:*scripts.local_modules/simple-test-framework/src/index.ts (1)
90-140: expect() matcher extensions are consistent and type-safe enough for this frameworkThe new
toContainandnotmatchers correctly handle arrays and strings, provide clear error messages, and match the declared typings. Using a genericTfortoBe/not.toBeand a looseranyfortoContainis a pragmatic choice here given the runtime type checks.local_modules/simple-test-framework/src/index.d.ts (1)
1-17: Typings correctly mirror the runtime APIThe updated declarations for
expect(includingtoContainandnot.{toContain,toBe}),runTestFile, andtestsRunnerall match the implementation insrc/index.ts. The internalTestFunctionalias and the non-exportedfindAndRunTestskeep the public surface minimal and clear.
This pull request updates the development environment and testing framework to use more recent versions of Node.js and TypeScript, enhances the custom test framework with new assertions, and adds comprehensive tests for the HTML minification logic. The changes improve compatibility, add useful test utilities, and increase test coverage.
Dependency and environment updates:
.github/workflows/dev.yml)typescriptdependency from version 3.9.10 to 5.9.3 in both the root andsimple-test-frameworkpackage, and updated the minimum Node.js engine requirement to 20.0.0 in the rootpackage.json. (local_modules/simple-test-framework/package.json,local_modules/simple-test-framework/package-lock.json,package.json) [1] [2] [3] [4]Testing framework improvements:
toContainandnot.toContainto theexpectAPI insimple-test-framework, allowing for more expressive tests involving arrays and strings. (local_modules/simple-test-framework/src/index.ts)Test coverage:
minifyContentsfunction, covering HTML minification, non-HTML passthrough, case and whitespace handling in file types, and robustness against invalid HTML. (src/minify/minifyContents.spec.ts)Summary by CodeRabbit
New Features
toContain()for validating array and string elements,not.toContain()for negated containment checks, andnot.toBe()for inequality assertions.Chores
✏️ Tip: You can customize this high-level summary in your review settings.