Skip to content

πŸ“ˆ Get real-time stocks from TradingView

Fix tests

Mathieu Colmonefa30dd439b3
diff --git a/tests/builtInIndicator.test.ts b/tests/builtInIndicator.test.ts
index 1c63de3..d55f53e 100644
--- a/tests/builtInIndicator.test.ts
+++ b/tests/builtInIndicator.test.ts
@@ -4,7 +4,7 @@ import utils from './utils';
describe('BuiltInIndicator', () => {
let client: TradingView.Client;
- let chart: any;
+ let chart: InstanceType<typeof client.Session.Chart>;
it('creates a client', async () => {
client = new TradingView.Client();
diff --git a/tests/indicators.test.ts b/tests/indicators.test.ts
index 600b051..6e57d22 100644
--- a/tests/indicators.test.ts
+++ b/tests/indicators.test.ts
@@ -33,7 +33,7 @@ describe('Indicators', () => {
});
let client: TradingView.Client;
- let chart: any;
+ let chart: InstanceType<typeof client.Session.Chart>;
it('creates a client', async () => {
client = new TradingView.Client();
@@ -71,16 +71,22 @@ describe('Indicators', () => {
console.log('Performances:', {
total: {
- trades: perfReport.all.totalTrades,
- perf: `${Math.round(perfReport.all.netProfitPercent * 10000) / 100} %`,
+ trades: perfReport?.all?.totalTrades,
+ perf: `${Math.round((
+ perfReport?.all?.netProfitPercent || 0
+ ) * 10000) / 100} %`,
},
buy: {
- trades: perfReport.long.totalTrades,
- perf: `${Math.round(perfReport.long.netProfitPercent * 10000) / 100} %`,
+ trades: perfReport?.long?.totalTrades,
+ perf: `${Math.round((
+ perfReport?.long?.netProfitPercent || 0
+ ) * 10000) / 100} %`,
},
sell: {
- trades: perfReport.short.totalTrades,
- perf: `${Math.round(perfReport.short.netProfitPercent * 10000) / 100} %`,
+ trades: perfReport?.short?.totalTrades,
+ perf: `${Math.round((
+ perfReport?.short?.netProfitPercent || 0
+ ) * 10000) / 100} %`,
},
});
diff --git a/tests/replayMode.test.ts b/tests/replayMode.test.ts
index 2ce4132..76c3a14 100644
--- a/tests/replayMode.test.ts
+++ b/tests/replayMode.test.ts
@@ -4,7 +4,7 @@ import utils from './utils';
describe('ReplayMode', () => {
let client: TradingView.Client;
- let chart: any;
+ let chart: InstanceType<typeof client.Session.Chart>;
it('creates a client', async () => {
client = new TradingView.Client();