Skip to content

🐛 Knip crashes when testEnvironment uses the object form in rstest config #2009

Description

@yslpn

Prerequisites

Reproduction url

Not available yet.

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

I wanted to enable Rstest prebundling for the jsdom test environment by adding
the new prebundle option:

import { defineConfig } from '@rstest/core';

export default defineConfig({
  testEnvironment: {
    name: 'jsdom',
    prebundle: 'auto',
  },
});

After changing testEnvironment from the string form to the object form,
running Knip crashes before it can report its analysis results.

Steps to reproduce

  1. Use @rstest/core 0.11.9 and knip 6.24.0.

  2. Add the object-form testEnvironment configuration shown above to
    rstest.config.ts.

  3. Run:

    pnpm run knip

Actual result

Knip terminates with an uncaught TypeError:

TypeError: Cannot read properties of undefined (reading 'startsWith')
    at .../knip/dist/WorkspaceWorker.js:410:54
    at Array.some (<anonymous>)
    at runPlugin (.../knip/dist/WorkspaceWorker.js:410:54)
    at async WorkspaceWorker.runPlugins (.../knip/dist/WorkspaceWorker.js:421:33)
    at async build (.../knip/dist/graph/build.js:147:35)
    at async run (.../knip/dist/run.js:40:109)
    at async main (.../knip/dist/cli.js:34:29)

[ELIFECYCLE] Command failed with exit code 1.

Expected result

Knip should complete successfully when Rstest's supported object form of
testEnvironment is used, or report a clear compatibility/configuration error
instead of crashing.

Environment

  • Node.js 24.16.0
  • pnpm 11.7.0
  • @rstest/core 0.11.9
  • knip 6.24.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions