Skip to content

charton API


charton API / @chart-on/core / testing / testDataSource

Function: testDataSource() ​

testDataSource(source, options): Promise<string[]>

Defined in: packages/core/src/data/conformance.ts:36

Check that a data source answers the requests the chart sends the way the chart expects (see "Writing an adapter" in the data sources guide), and return what it found wrong; an empty list means it conforms. Run it from your own tests against your adapter, with a symbol that has at least 3 × limit bars of history:

ts
expect(await testDataSource(source, { symbol: 'ABC', interval: '1h' })).toEqual([]);

It checks every response for ascending, unique, valid bars and at most limit of them; that an initial load returns the newest bars; that to is exclusive and from inclusive and both select the newest bars in range; that paging back returns older bars page by page, and that no older bars exist once a page says atStart; and that a request whose signal is already aborted settles.

Parameters ​

source ​

DataSource

options ​

DataSourceCheckOptions

Returns ​

Promise<string[]>