Skip to content

Releases: stevez/nextcov

v1.0.0

27 Dec 18:29

Choose a tag to compare

[1.0.0] - 2024-12-27

🎉 Stable Release

nextcov has reached 1.0! This release marks API stability and production readiness.

What nextcov provides:

  • V8 code coverage for Next.js and Vite applications with Playwright E2E tests
  • Merge Playwright E2E coverage with Vitest unit test coverage
  • Support for React Server Components testing through E2E
  • Auto-detection of dev mode vs production mode
  • Client-only mode for Vite, static sites, and SPAs

Key features:

  • nextcov init - Interactive project setup
  • nextcov merge - Merge multiple coverage reports
  • nextcov check - Detect V8 coverage blind spots and configuration issues

Quality metrics:

  • 777 tests passing
  • 74% code coverage
  • Zero technical debt (no TODO/FIXME markers)
  • Strict TypeScript with full type safety
  • Professional error handling throughout

Since 0.1.0:

  • 12 minor releases with continuous improvements
  • Comprehensive documentation with two example projects
  • Battle-tested in production applications

v0.12.2

27 Dec 17:57
858e100

Choose a tag to compare

[0.12.2] - 2024-12-27

Added

  • Project Configuration Checks in check command - Now scans project configuration in addition to code patterns

    • Separate output sections for "Project Configuration" and "Code Pattern Issues"
    • Severity levels: error (✗), warning (⚠), info (ℹ)

    Configuration checks:

    Check Severity Description
    Outdated browserslist error Browser targets don't support ?. and ?? (min: chrome 111, edge 111, firefox 111, safari 16.4)
    Babel detected error Babel config found (may transpile modern syntax, breaking V8 coverage)
    Playwright not found error @playwright/test not in devDependencies (required for nextcov)
    Missing browserslist warning No browserslist config - ?. and ?? may be transpiled, causing phantom branches
    Jest detected warning Jest config found (consider using Vitest for V8 coverage)
    Source maps not enabled warning productionBrowserSourceMaps: true not found in next.config
    Vitest not found info Vitest not in devDependencies (recommended for V8 coverage)
  • New files:

    • src/linter/detectors/project-config.ts - Project configuration detector
    • src/linter/config-scanner.ts - Configuration scanner wrapper
    • src/linter/detectors/__tests__/project-config.test.ts - Detector tests (20 tests)
    • src/linter/__tests__/config-scanner.test.ts - Scanner tests (7 tests)
  • New --skip-config flag for check command - Skip project configuration checks

    npx nextcov check              # config only (no paths)
    npx nextcov check src/         # config + source code
    npx nextcov check src/ --skip-config  # source code only

Changed

  • check command behavior - Config is checked by default, source only scanned if paths provided

    • npx nextcov check → config only
    • npx nextcov check src/ → config + source
    • npx nextcov check src/ --skip-config → source only
  • check command output - Now shows two sections:

    Project Configuration:
    ─────────────────────────────────────────────────────────
      ✗ Browserslist targets outdated browsers
      ⚠ Jest detected - consider using Vitest for V8 coverage
    
    V8 Coverage Readiness Check
    ═══════════════════════════════════════════════════════════
    ...code pattern issues...
    
  • Exit code behavior - Returns 1 if config errors OR code issues found (unless --ignore-patterns)

Tests

  • Total tests: 777 passing (up from 742)
  • New tests for config detection, scanning, and --skip-config flag

v0.12.1

27 Dec 05:13

Choose a tag to compare

[0.12.1] - 2024-12-27

Added

  • Dependencies - Added for enhanced check command output

    • chalk@^4.1.2 - Terminal color output for ESLint-style formatting
  • Documentation - Enhanced README with comprehensive CLI command reference

    • Added "CLI Commands" section documenting all three commands (init, merge, check)
    • Added "Detecting V8 Coverage Blind Spots" section with problem description, solutions, and real-world impact
    • Included before/after code examples showing how to fix blind spots
    • Added CI integration examples for GitHub Actions
    • Documented real-world metrics: refactoring JSX patterns increased trackable branches from 433 to 445 (+12 paths)

Changed

  • Console Reporter - Enhanced with colored output using chalk
    • ESLint-style colored output for better readability
    • Bold code snippets in verbose mode
    • Color-coded file paths, warnings, and messages

v0.12.0

27 Dec 04:55
d0b99ca

Choose a tag to compare

[0.12.0] - 2024-12-26

Added

  • New check CLI command - Scan codebase for V8 coverage blind spots in JSX code

    • Detects JSX ternary operators: {cond ? <A /> : <B />} that V8 cannot track for branch coverage
    • Detects JSX logical AND operators: {cond && <Component />} that V8 cannot track for branch coverage
    • Only flags patterns inside JSX expression containers ({...}), not variable assignments
    • Usage: npx nextcov check [paths...] [options]
    • Options:
      • --verbose - Show code snippets in console output
      • --json - Output results as JSON
      • --ignore-patterns - Exit with 0 even if issues found (for CI warnings)
    • Returns exit code 0 (clean), 1 (issues found), or 2 (error)
    • Scans .js, .jsx, .ts, .tsx files
    • Automatically ignores node_modules/, .next/, dist/, build/, .git/, coverage/
    • Example: npx nextcov check src/ --verbose
  • JSX Pattern Detector - AST-based detection using Babel parser

    • Uses @babel/parser to parse JSX/TypeScript code into AST
    • Uses @babel/traverse to walk AST and find problematic patterns
    • Gracefully handles syntax errors and non-JSX files
    • Tracks parent nodes to distinguish JSX expression containers from variable assignments
    • Extracts code snippets for verbose output
    • Comprehensive test suite with 18 tests (92.68% statement coverage)
  • File Scanner - Glob-based directory scanning

    • Scans directories recursively for JS/TS files
    • Supports specific file paths or directory patterns
    • Custom ignore patterns support
    • Relative file path output
    • Comprehensive test suite with 13 tests (95% statement coverage)
  • Console Reporter - Formatted output for scan results

    • Human-readable console output with file:line:column locations
    • JSON output mode for programmatic consumption
    • Verbose mode with code snippets
    • Issue grouping by file
    • Help text with remediation guidance
    • Comprehensive test suite with 13 tests (100% coverage)
  • Dependencies - Added for JSX pattern detection

    • @babel/traverse@^7.28.5 - AST traversal with visitor pattern
    • @types/babel__traverse@^7.28.0 - TypeScript type definitions

Changed

  • CLI bundle size increased - From 74 KB to 80.13 KB (~8% increase)
    • Babel dependencies added for JSX pattern detection (~6 KB impact)
    • Acceptable trade-off for check command functionality

Tests

  • Improved test coverage - Added 56 new tests across 4 test files
    • Total tests: 742 passing (up from 686)
    • New test files:
      • src/linter/detectors/__tests__/jsx-patterns.test.ts (18 tests)
      • src/linter/__tests__/scanner.test.ts (13 tests)
      • src/linter/__tests__/reporter.test.ts (13 tests)
      • src/cli/commands/__tests__/check.test.ts (12 tests)
    • Linter module coverage: 98.46% statement, 100% branch, 100% function

v0.11.2

27 Dec 01:35
03aac83

Choose a tag to compare

[0.11.2] - 2024-12-26

Changed

  • Reduced public API surface for smaller bundle size - Minimized main entry point exports
    • Removed 60+ internal exports from src/index.ts that users should never import directly
    • Removed default value exports (DEFAULT_NEXTCOV_CONFIG, DEFAULT_INCLUDE_PATTERNS, etc.) - only needed internally
    • Removed utility function exports (normalizePath) - only needed internally
    • Kept only 5 essential runtime exports: loadNextcovConfig, resolveNextcovConfig, mergeCoverage, printCoverageSummary, printCoverageComparison
    • Type definitions (NextcovConfig, etc.) remain available for TypeScript users
    • Most users import from nextcov/playwright instead of main entry point
    • Bundle size reduced from 143 KB to 27.28 KB (~81% reduction)
    • Updated README.md API documentation to reflect minimal public API

v0.11.1

27 Dec 01:06
efd9522

Choose a tag to compare

[0.11.1] - 2024-12-26

Changed

  • Comprehensive codebase reorganization - Restructured entire codebase into focused domain folders for better maintainability and scalability

    • Phase 1 (v0.11.0): Split converter.ts and constants.ts into modular converter/ and parsers/ folders
    • Phase 2: Organized utilities into utils/ folder
      • Moved config.ts, logger.ts, constants.ts, dev-mode-extractor.ts to src/utils/
      • Created utils/index.ts for centralized exports
    • Phase 3: Organized CLI into cli/ folder structure
      • Split cli.ts into cli/commands/merge.ts and cli/index.ts
      • Moved init.ts to cli/commands/init.ts
      • Created cli/index.ts as main CLI entry point
    • Phase 4: Organized core processing modules into core/ folder
      • Moved processor.ts, v8-reader.ts, reporter.ts, sourcemap-loader.ts to src/core/
      • Created core/index.ts for centralized exports
      • Removed unnecessary converter.ts re-export layer
    • Phase 5: Organized worker modules into worker/ folder
      • Moved ast-worker.ts and worker-pool.ts to src/worker/
      • Created worker/index.ts for centralized exports
      • Updated worker path resolution for new dist/worker/ build location
      • Updated tsup config to output workers to dist/worker/
    • Phase 6: Organized merger module into merger/ folder
      • Split merger.ts (968 lines) into 3 focused files:
        • merger/core.ts (842 lines) - CoverageMerger class and merging logic
        • merger/printer.ts (65 lines) - Console output formatting
        • merger/utils.ts (86 lines) - Helper functions and lookups
      • Created merger/index.ts for centralized exports
  • Refactored imports to use TypeScript path aliases - Replaced relative imports (../../) with clean @/ prefix

    • Configured TypeScript path aliases in tsconfig.json with @/* mappings
    • Added tsc-alias to build script for path resolution in compiled JavaScript
    • Updated vitest.config.ts with resolve.alias configuration
    • Migrated 35+ files across all modules (cli, core, converter, merger, utils, worker, collector, parsers)
    • Updated dynamic imports and vi.mock paths in CLI commands and tests

Internal

  • Build system enhancement - Added tsc-alias step after tsup compilation
    • Build script now: tsup && tsc-alias to resolve path aliases in output
  • TypeScript error fixes - Fixed type inference issues in test files
    • Added FileCoverageData type casts to .toJSON() calls in coverage tests
    • Fixed incorrect test assertions with extra parameters
    • Removed non-existent exports (setVerbose, WorkerResult)
  • New folder structure - Codebase now organized into 9 domain-focused folders:
    • cli/ - Command-line interface and commands
    • core/ - Core processing modules (processor, reporter, reader, source maps)
    • utils/ - Shared utilities (config, logger, constants, extractors)
    • worker/ - Worker thread parallelization
    • merger/ - Coverage merging logic
    • converter/ - V8-to-Istanbul conversion
    • parsers/ - Bundler-specific URL parsers
    • collector/ - Coverage collection (CDP, dev mode, production)
    • playwright/ - Playwright test fixtures
  • All 686 tests passing with full TypeScript type checking
  • No API changes - this is purely an internal code organization improvement

v0.11.0

26 Dec 14:55
04a64e7

Choose a tag to compare

[0.11.0] - 2024-12-26

Changed

  • Refactored converter and parsers into modular structure - Split large monolithic files into focused modules for better maintainability
    • Split converter.ts (2,117 lines) into converter/ folder with 4 modules:
      • converter/index.ts - Main CoverageConverter class (1,007 lines)
      • converter/merge.ts - V8 coverage merging (82 lines)
      • converter/sanitizer.ts - Source map sanitization (340 lines)
      • converter/coverage-fixes.ts - Istanbul coverage fixes (754 lines)
    • Created parsers/ folder (6 modules, 553 lines total):
      • Extracted bundler-specific patterns from constants.ts
      • parsers/nextjs.ts - Next.js URL patterns (101 lines)
      • parsers/vite.ts - Vite URL patterns (93 lines)
      • parsers/webpack.ts - Webpack URL patterns (94 lines)
      • parsers/sourcemap.ts - Source map patterns (92 lines)
      • parsers/url-utils.ts - URL utilities (68 lines)
    • Reduced constants.ts from 317 to 92 lines (-71%)
    • All exports remain backward compatible - no breaking changes for users

Internal

  • Improved test coverage - Added comprehensive tests for new modules (+2,047 test lines)
    • Coverage improved from 72.75% to 77.53% (+4.78%)
    • Created 9 new test files for parsers and converter modules
    • All 678 tests passing

v0.10.1

26 Dec 05:04

Choose a tag to compare

[0.10.1] - 2024-12-26

Fixed

  • nextcov init now uses pinned dependency versions - cross-env, start-server-and-test, and concurrently now use specific version ranges (^7.0.3, ^2.0.8, ^9.1.0) instead of "latest" for reproducible builds

v0.10.0

26 Dec 04:48
65acbc1

Choose a tag to compare

[0.10.0] - 2024-12-25

Added

  • nextcov init command - Interactive scaffolding for nextcov setup

    • Creates global-setup.ts, global-teardown.ts, and test-fixtures.ts
    • Modifies playwright.config.ts with nextcov configuration
    • Adds npm scripts (dev:e2e, build:e2e, start:e2e, test:e2e, coverage:merge) to package.json
    • Modifies next.config.ts with E2E mode settings for source maps
    • Options: --client-only, --e2e-dir, --js, --force, -y (skip prompts)
  • Coverage mode selection in nextcov init - Choose between Full and Client-only modes

    • Full mode: Creates global-setup.ts with server coverage, dev:e2e uses --inspect
    • Client-only mode: Creates global-setup.ts for client coverage, simpler dev:e2e script, collectServer: false in config
  • initCoverage() function - Unified entry point for globalSetup

    • Works for both client-only and full (client + server) modes
    • Replaces the confusing pattern of calling startServerCoverage() for client-only mode
    • Example: await initCoverage(config) in global-setup.ts
  • Vite support - Client-only coverage for Vite applications

    • Detects Vite source URLs (e.g., http://localhost:5173/src/App.tsx)
    • Use collectServer: false in nextcov config for Vite apps
    • Full example in README under "Vite Support" section
  • text-summary in default reporters - Both nextcov init templates and nextcov merge CLI now include text-summary reporter by default

  • Component test coverage in merge script - coverage:merge script now includes coverage/component directory

    • Generated script: nextcov merge coverage/unit coverage/component coverage/e2e -o coverage/merged
  • --no-strip option for nextcov merge - Disable automatic stripping of import statements and directives

    • By default, merge strips import statements and 'use client'/'use server' directives for accurate merged coverage
    • Use --no-strip to preserve original coverage data

Fixed

  • Client-only mode in nextcov init - Fixed several issues with client-only setup

    • dev:e2e script now correctly uses E2E_MODE=true instead of --inspect flag
    • Global teardown template includes correct comment for client-only mode
    • Playwright config correctly sets collectServer: false
  • Full mode (client + server) in nextcov init - Fixed server coverage setup

    • start:local script includes NODE_V8_COVERAGE for proper server coverage collection
    • Webpack config properly handles isServer parameter for source map paths
    • Added devtoolModuleFilenameTemplate for accurate server-side source mapping
  • Config loading in CJS projects - Fixed loadNextcovConfig() not loading config from playwright.config.ts in projects without "type": "module" in package.json

    • In CJS projects, named exports like export const nextcov = {...} appear under module.default.nextcov instead of module.nextcov
    • Now checks multiple locations: module.nextcov, module.default?.nextcov, and actualConfig?.nextcov

v0.9.4

24 Dec 20:47
46931fa

Choose a tag to compare

[0.9.4] - 2024-12-24

Added

  • Dual ESM/CJS build - Package now exports both ESM and CommonJS formats
    • ESM: dist/index.js, dist/playwright/index.js
    • CJS: dist/index.cjs, dist/playwright/index.cjs
    • Enables compatibility with tools that require CJS (e.g., Playwright's TypeScript loader when using symlinks via yalc/npm link)
    • Uses tsup bundler for reliable dual-format output

Changed

  • Build system migrated to tsup - Replaced tsc with tsup for bundling
    • Adds shims: true for import.meta.url compatibility in CJS
    • Adds cjsInterop: true for proper default export handling
    • Worker file (ast-worker.js) built as separate ESM entry

Fixed

  • Worker path resolution for bundled code - findWorkerPath() now checks parent directory for ast-worker.js
    • Fixes worker loading when code is bundled into dist/playwright/ subdirectory
  • ESM/CJS interop for ast-v8-to-istanbul - Added runtime detection to unwrap default export in CJS context
    • Fixes (0, import_ast_v8_to_istanbul.default) is not a function error in CJS mode