Skip to content

Separate integration tests that require build artifacts #130

Description

@groupsky

Problem

Currently, integration tests that use dynamic import() are mixed with unit tests:

  • Unit tests use mocked dependencies and work without build
  • Integration tests load real packages via import() and require build artifacts from dist/
  • CI must build before ALL tests run, even though most don't need it

Example: packages/driver-loader/src/loader.test.ts contains both:

  • Unit tests with mocked deps.importModule (no build needed)
  • Integration test that calls real import('ya-modbus-driver-xymd1') (build needed)

Proposed Solution

Extract integration tests into separate files or test groups:

Option 1: Separate Files

packages/driver-loader/src/loader.test.ts          # Unit tests (no build)
packages/driver-loader/src/loader.integration.ts   # Integration tests (needs build)

Option 2: Jest Test Groups

// jest.config.cjs
module.exports = {
  projects: [
    {
      displayName: 'unit',
      testMatch: ['**/*.test.ts'],
      testPathIgnorePatterns: ['integration'],
    },
    {
      displayName: 'integration',
      testMatch: ['**/*.integration.ts'],
    },
  ],
}

Benefits

  • Faster CI: Run unit tests without build
  • Clear separation: Developers know which tests need build
  • Better organization: Integration tests have different requirements (slower, need build)

CI Workflow

With separation, CI could:

  1. npm ci
  2. npm run lint (no build needed)
  3. npm run test:unit (no build needed)
  4. npm run build
  5. npm run test:integration (uses build artifacts)

Files to Check

Search for integration tests that might need build:

rg -l "describe.*integration" --type ts
rg -l "import\(" packages --type ts

Most likely candidates:

  • packages/driver-loader/src/loader.test.ts - confirmed has integration test
  • Check other packages for similar patterns

References

  • Current CI workflow: .github/workflows/ci.yml
  • Jest config: jest.config.cjs
  • Testing guidelines: docs/agents/testing.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions