PackagePackagetypeA library you install and call yourself.See every one →What this type is →by SAPby SAPoriginPublished by SAP itself. A visible facet, never an input to a reading — a dormant official plugin reads exactly like a dormant independent one.See every one →

@cap-js/cds-test

Test support for CAP Node.js, installed as a dev dependency: it starts the project's server for the test, hands the test an HTTP client bound to it, and carries the assertions.

The code that starts a CAP server for a test, points an HTTP client at it and carries the assertions used to ship inside @sap/cds. It is this package now, added as a dev dependency and reached from a test file through cds.test(), which launches the project under test and returns helpers already bound to its URL and port. It covers the service boundary, so a handler and a query can be asserted in the same test without a deployed system. It picks no test runner: capire names Vitest, Jest, Mocha and Node's own runner, and a project keeps whichever it has. Driving a UI, and anything needing a real BTP binding, stays outside it.

Facts

Latestv1.0.2ReleasedLast pushLicenceApache-2.0

Where it sits

Lives in
Provides
TestingCAPTestingcapabilityProving the service still does what it did — against the model and the handlers, without a deployed system and without a database somebody has to keep clean.
Flavors
Requires
@sap/cds≥ 9.8@sap/cdsartifactThe peer range, as published.

Who is behind it

SAP Cloud Application Programming ModelSAP Cloud Application Programming ModelOrganisationMaintains this
In the atlas: maintains 34
@cap-js
maintainerBob den OsPersonContributes to this
In the atlas: contributes to 13
@BobdenOs
Christian GeorgiPersonContributes to this
In the atlas: maintains 1, contributes to 53
@chgeo
Christian SchüringsPersonContributes to this
In the atlas: contributes to 25
@cschuerings
Daniel HutzelPersonContributes to this
In the atlas: contributes to 32, wrote 3
@danjoa
Johannes VogelPersonContributes to this
In the atlas: contributes to 25
@johannes-vogel
Mauricio LaufferPersonContributes to this
In the atlas: maintains 16, contributes to 41, wrote 4
@mauriciolauffer
Patrice BenderPersonContributes to this
In the atlas: contributes to 11
@patricebender
PaulPersonContributes to this
In the atlas: contributes to 12
@PDT42
sjvansPersonContributes to this
In the atlas: contributes to 45
@sjvans
Stefan RudiPersonContributes to this
In the atlas: contributes to 13, wrote 5
@stefanrudi
10 contributors

What it declares

Every artifact

Type
Package
Origin
By SAP
Runtime
Node.js

As a package

Declared for
>=9.8
Where it runs
does not say
Distributed through
npm

Connections1

Install

npm add @cap-js/cds-test

Derived from the package name. No recipe recorded; the README has the configuration.

README

quoted from cap-js/cds-test under Apache-2.0, read
cap-js/cds-test/README.mdOn GitHub

Test Support for CAP Node.js

About this project

This is a library with test utilities for CAP Node.js applications, like

  • Starting and stopping a CAP server before and after tests
  • A bound HTTP client for the server
  • chai-like assertion helpers

Requirements and Setup

In your application project, just install the package as dev dependency:

npm add -D @cap-js/cds-test

Usage

Add a simple test file test/bookshop.test.js with this content:

const cds = require('@sap/cds')
const { GET, expect } = cds.test (__dirname+'/..')

describe('Sample tests', () => {

  it('serves Books', async () => {
    const { data } = await GET `/odata/v4/catalog/Books`
    expect(data.value.length).to.be.greaterThanOrEqual(5)
  })
})

Run it with Vitest, for example:

npx vitest

Or with Jest:

npx jest

node --test, and mocha runners are supported, too, though with less coverage in real-life projects.

Documentation

See the CAP documentation on cds.test for more.

Support, Feedback, Contributing

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

Security / Disclosure

If you find any bug that may be a security problem, please follow our instructions at in our security policy on how to report it. Please do not create GitHub issues for security-related doubts or problems.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

Licensing

Copyright 2024-2026 SAP SE or an SAP affiliate company and cds-test contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

Apache-2.0, read

History

Latest

v1.0.2

Fixes 3

Notes
Fixed
  • Buffer request bodies are no longer serialized via JSON.stringify()
  • In chest-powered tests, inspectPort configuration will be passed to node:test.run(...) when debugging
  • In chest-powered tests, concurrency of node:test.run(...) will be limitted to 1 to enable debugging
  1. v1.0.1

    Fixes 1

    Notes
    Fixed
    • cds-test no longer fails to find test files if it encounters a symlinked directory.
  2. v1.0.0dated in the atlas

    Removed 1, Features 3, Changed 3, Fixes 2

    Notes
    Changed
    • Usage of axios has been removed in favor of the Fetch API, which is available in Node.js 18 and later. This change allows for a more modern and native approach to making HTTP requests, eliminating the need for an external dependency. For compatibility, if it's is installed explicitly, the axios library will used.

    • When running in Jest, the expect from cds.test now returns a built-in implementation which covers the most common matchers with the common chai API. In other runners, the expect from cds.test returns the chai.expect implementation as before.

    • Assertion stack traces no longer contain frames of cds-test's own implementation.

    Removed
    • Dependencies to axios -> install it yourself if you want to use axios.
    Added
    • Support for the Vitest test runner.
    • Property cds.test.defaults as a shortcut for cds.test.axios.defaults, which is deprecated now.
    • Property cds.test.defaults.path to set a common path prefix for subsequent requests.
    Fixed
    • cds.test can now be used in combination with ESM modules without issues.
    • cds.test can now be used in combination with chai 6 and chai-as-promised 8.
  3. v0.4.1

    Fixes 2

    Notes
    Fixed
    • it.each() only uses the first entry of nested arrays
    • Non-axios variant returns response status field also as code.
    Fixed
  4. v0.4.0

    Features 2

    Notes
    Added
    • Support for err.cause in Axios errors
    • Experimental support for fetch instead of Axios
  5. v0.3.0

    Features 1, Changed 1, Fixes 1

    Notes
    Added
    • add toBeNull matcher to Jest expectations
    Changed
    • Many changes to the experimental test runner.
    Fixed
    • Prevent jest and mocha from giving random timeout errors if cds.test.data.reset is used.
  6. v0.2.0

    Changed 1

    Notes
    Changed
    • @sap/cds 8.8.0 is required at the minimum
  7. v0.1.2

    Features 1

    Notes
    Added
    • Publish to NPM with provenance attestation
  8. v0.1.1

    Fixes 1

    Notes
    Fixed
    • Cleanups
  9. v0.1.0

    Features 1

    Notes
    Added
    • Initial version
18,779downloads per week, npm
Weekly downloads for @cap-js/cds-test26 complete calendar weeks from 2026-04-20 to 2026-10-18; the latest total is 18779.20 Apr – 26 Apr: 21,29827 Apr – 3 May: 23,8794 May – 10 May: 23,77511 May – 17 May: 23,28718 May – 24 May: 26,24725 May – 31 May: 24,8701 Jun – 7 Jun: 18,9938 Jun – 14 Jun: 26,59615 Jun – 21 Jun: 28,01822 Jun – 28 Jun: 25,03729 Jun – 5 Jul: 22,5716 Jul – 12 Jul: 25,33613 Jul – 19 Jul: 26,44720 Jul – 26 Jul: 26,44127 Jul – 2 Aug: 29,3143 Aug – 9 Aug: 30,57510 Aug – 16 Aug: 28,32817 Aug – 23 Aug: 32,33624 Aug – 30 Aug: 27,18131 Aug – 6 Sept: 25,7077 Sept – 13 Sept: 18,91114 Sept – 20 Sept: 24,21521 Sept – 27 Sept: 28,41328 Sept – 4 Oct: 31,2855 Oct – 11 Oct: 25,64212 Oct – 18 Oct: 18,779
Testing
  1. com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versionsfrom CAP
  2. cds-cucumberGherkin scenarios driving a running CAP servicefrom CAP
  3. sapbrunoTerminal UI running Bruno collections against a CAP servicefrom CAP
  4. cds-launchpad-pluginSandbox launchpad for all SAPUI5 apps in a CAP workspacefrom CAP
  5. enforce-export-coverageStatic check that each exported TypeScript function has a testfrom General
  6. @sap-ux/fe-mockserver-plugin-cdsFiori Elements mock server plugin taking a CDS file as metadatafrom CAP
  7. @saptools/brunoRunner for Bruno collections against XSUAA-protected CF appsfrom BTP/BAIP

Details

Sources5
npm registrydiscovered herechecked
GitHub APIdiscovered here, cap-jschecked
npm registry, @cap-js/cds-testversion, releases, installschecked
github.com/git+https://github.com/cap-js/cds-test.gittree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
runtimesnode
declared for>=9.8
latestv1.0.2
first release
releases and cadence10, ~30d median
discovered vianpm registry, GitHub API · cap-js
first seen in the atlas
ecosystem and domaincap, developer-experience
Flavors1
Node.js
“Test Support for CAP Node.js” — cap-js/cds-test — repositorychecked
Contributors10
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:cap-js-cds-test
JSON
/artifacts/cap-js-cds-test.json
MCP
Connecting an agent