Skip to content

Tests configure CDS via process.env.cds_requires_* string-JSON instead of profiles/config #486

Description

@sjvans

Several test files configure CDS by assigning string-JSON to process.env.cds_requires_* (and similar) at module top, instead of using cds's normal profile / .cdsrc.json / cds.test() config mechanism.

Sites:

  • test/tracing-messaging-inboxed.test.js, test/tracing-messaging-persistent-outbox.test.js, test/tracing-messaging-without-outbox.test.jsprocess.env.cds_requires_messaging = JSON.stringify({ ... })
  • test/logging.test.jsprocess.env.cds_requires_telemetry_tracing = JSON.stringify({ exporter: false }) and process.env.cds_log = JSON.stringify({ ... })
  • test/passport.test.jsprocess.env.cds_requires_scheduling = 'false'
  • test/tracing-attributes.test.jsprocess.env.cds_remote_native__fetch = 'true'

Why this is worth fixing

  • Fragile & load-order-sensitive: the assignment must run before any @sap/cds require, or it's silently ignored. This module-load-order coupling is exactly what forced the delete cds.env hack that test: run full suite on HANA + fix two HANA span/metric bugs (#477 §2, §5) #481 had to remove (reading cds.env at collection time froze the singleton before the profile applied).
  • Stringly-typed: hand-built JSON strings, no validation, easy to get subtly wrong.
  • Bypasses the intended mechanism: cds already supports --profile + .cdsrc.json profiles and cds.test(dir, ...args) options; most of these overrides could be expressed there instead.

Follow-up

Move these config overrides to proper --profile / .cdsrc.json profiles or cds.test(...) arguments where possible, and reduce reliance on process.env.cds_requires_*.

Origin: maintainer review on #481 (the delete cds.env fragility thread). Part of the test-quality cluster (#477 / #478 / #475).

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