Skip to content

rs test / rs lint run with an empty config when define.test() / define.lint() is missing: intended or an oversight? #490

Description

@fi3ework

What happens

When rstack.config.ts only defines define.lint() and define.fmt() (no define.test()), rs test still starts Rstest with an empty config {}, scans the whole directory with the default include, and runs whatever it finds.

A real case is the rspack-examples repo. The root rstack.config.ts has lint, fmt and staged only. rstest/module-federation-node/host/ has its own rstest.config.ts that registers remote/* through the @module-federation/rstest plugin. Running rs test at the repo root collects host/tests/federated-modules.test.ts too, but with the root's empty config and no federation plugin, so it fails with Cannot find module 'remote/formatPrice' (exit 1). Running rstest inside host/ passes. A minimal fixture with the same layout reproduces the same result.

Another case is a repo that uses vitest. rs test picks up src/sum.test.ts and fails while loading it with Vitest failed to find the current suite (exit 1).

rs lint behaves the same way: without define.lint() it runs with [], prints Lint passed (2 files, 0 rules) and exits 0, reporting nothing for debugger statements or unused variables.

Environment: rstack 0.7.4, @rstest/core 0.11.12 (rstack itself depends on ~0.11.12, so it is always installed alongside rstack), vitest 5.0.1, Node 26.5.0.

History

I went through the git history and the issues and could not find this fallback being discussed:

  • The {} fallback for test comes from 2dc4974 (feat: support for defining test config). The [] fallback for lint comes from c7b4ec1 (feat: add lint command placeholder). Both were pushed directly with no linked PR, and neither commit message mentions the missing-definition case.
  • The docs say "Define only the configurations your project needs" but do not say what happens when you invoke a tool that has no definition.
  • By contrast, rs staged refuses when define.staged() is missing (No define.staged config found). It is the only command that handles the missing case on purpose.

So this looks like a default that came with ?? {} rather than an explicit product decision.

Question

When the matching define.* is missing, what should rs test / rs lint do?

  • Keep the current behavior: treat it as define.test({}) and run. If so, this should be documented, so users know that rs test at a monorepo root will pick up nested projects and tests written for other runners.
  • Align with rs staged: exit with an error that asks for define.test().

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions