Skip to content

📈 Get real-time stocks from TradingView

Fix 'max number of studies...' error

Mathieu Colmon4a69f8ff071e
diff --git a/tests/allErrors.test.ts b/tests/allErrors.test.ts
index 2f8cf96..426ddc4 100644
--- a/tests/allErrors.test.ts
+++ b/tests/allErrors.test.ts
@@ -159,10 +159,7 @@ describe('AllErrors', () => {
)('throws an error when setting an invalid study option value', async () => {
console.log('Testing "Invalid value" error:');
- const client = new TradingView.Client({
- token,
- signature,
- });
+ const client = new TradingView.Client({ token, signature });
const chart = new client.Session.Chart();
chart.setMarket('BINANCE:BTCEUR'); // Set a market
diff --git a/tests/indicators.test.ts b/tests/indicators.test.ts
index 6deea41..33c80dc 100644
--- a/tests/indicators.test.ts
+++ b/tests/indicators.test.ts
@@ -1,6 +1,9 @@
import { describe, it, expect } from 'vitest';
import TradingView from '../main';
+const token = <string>process.env.SESSION;
+const signature = <string>process.env.SIGNATURE;
+
describe('Indicators', () => {
const indicators: { [name: string]: TradingView.PineIndicator } = {};
@@ -35,17 +38,19 @@ describe('Indicators', () => {
let client: TradingView.Client;
let chart: InstanceType<typeof client.Session.Chart>;
- it('creates a client', async () => {
- client = new TradingView.Client();
+ const noAuth = !token || !signature;
+
+ it.skipIf(noAuth)('creates a client', async () => {
+ client = new TradingView.Client({ token, signature });
expect(client).toBeDefined();
});
- it('creates a chart', async () => {
+ it.skipIf(noAuth)('creates a chart', async () => {
chart = new client.Session.Chart();
expect(chart).toBeDefined();
});
- it('sets market', async () => {
+ it.skipIf(noAuth)('sets market', async () => {
chart.setMarket('BINANCE:BTCEUR', {
timeframe: '60',
});
@@ -60,7 +65,7 @@ describe('Indicators', () => {
expect(chart.infos.full_name).toBe('BINANCE:BTCEUR');
});
- it.concurrent('gets performance data from SuperTrend strategy', async () => {
+ it.skipIf(noAuth).concurrent('gets performance data from SuperTrend strategy', async () => {
const SuperTrend = new chart.Study(indicators.SuperTrend);
let QTY = 10;
@@ -109,7 +114,7 @@ describe('Indicators', () => {
SuperTrend.remove();
}, 10000);
- it.concurrent('gets data from MarketCipher B study', async () => {
+ it.skipIf(noAuth).concurrent('gets data from MarketCipher B study', async () => {
const CipherB = new chart.Study(indicators.CipherB);
const lastResult: any = await new Promise((resolve) => {
@@ -132,12 +137,12 @@ describe('Indicators', () => {
CipherB.remove();
});
- it('removes chart', () => {
+ it.skipIf(noAuth)('removes chart', () => {
console.log('Closing the chart...');
chart.delete();
});
- it('removes client', async () => {
+ it.skipIf(noAuth)('removes client', async () => {
console.log('Closing the client...');
await client.end();
});