Skip to content

Commit 02d690b

Browse files
committed
chore: moved test configurations to separate file
also, they are now editable via environment variables
1 parent 126370d commit 02d690b

File tree

6 files changed

+26
-24
lines changed

6 files changed

+26
-24
lines changed

__tests__/integration/configuration/config.js.template

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ module.exports = {
4646
},
4747
*/
4848

49-
// Integration test configs
50-
integrationTest: {
51-
logOutputFolder: 'tmp/', // Should match .github/workflows/integration-test.yml -> upload-artifact
52-
consoleLevel: 'silly',
53-
wsUpdateDelay: 1000,
54-
walletStartTimeout: 60000,
55-
},
56-
5749
// Optional config so you can set the token you want to use in this wallet
5850
// If this parameter is set you don't need to pass your token when getting balance or sending tokens
5951
tokenUid: '',
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* This file contains the configurations specific for the integration tests on the Wallet Headless.
3+
* Those values are also editable via envrionment variables
4+
*/
5+
6+
module.exports = {
7+
// On CI, should match .github/workflows/integration-test.yml -> upload-artifact
8+
logOutputFolder: process.env.TEST_LOG_OUTPUT_FOLDER || 'tmp/',
9+
10+
// Console level used on winston
11+
consoleLevel: process.env.TEST_CONSOLE_LEVEL || 'silly',
12+
13+
// Defines how long tests should wait before consulting balances after transactions
14+
wsUpdateDelay: process.env.TEST_WS_UPDATE_DELAY || 1000,
15+
16+
// Defines for how long the startMultipleWalletsForTest can run
17+
walletStartTimeout: process.env.TEST_WALLET_START_TIMEOUT || 60000,
18+
};

__tests__/integration/txLogger.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-console */
22

33
import winston from 'winston';
4-
import config from '../../src/config';
4+
import testConfig from './configuration/test.config';
55

66
export const loggers = {
77
/**
@@ -68,15 +68,15 @@ export class TxLogger {
6868
winston.format.timestamp(),
6969
winston.format.colorize(),
7070
),
71-
level: config.integrationTest.consoleLevel || 'silly',
71+
level: testConfig.consoleLevel || 'silly',
7272
}),
7373
new winston.transports.File({
7474
format: winston.format.combine(
7575
winston.format.timestamp(),
7676
winston.format.prettyPrint()
7777
),
78-
filename: `${config.integrationTest.logOutputFolder}${this.#instanceFilename}`,
79-
level: config.integrationTest.consoleLevel || 'silly',
78+
filename: `${testConfig.logOutputFolder}${this.#instanceFilename}`,
79+
level: testConfig.consoleLevel || 'silly',
8080
colorize: false,
8181
})
8282
]

__tests__/integration/utils/test-utils-integration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import supertest from 'supertest';
44
import { HathorWallet, wallet } from '@hathor/wallet-lib';
55
import app from '../../../src';
66
import { loggers } from '../txLogger';
7-
import config from '../../../src/config';
7+
import testConfig from '../configuration/test.config';
88

99
const request = supertest(app);
1010

@@ -82,7 +82,7 @@ export class TestUtils {
8282
* @returns {Promise<void>}
8383
*/
8484
static async pauseForWsUpdate() {
85-
await TestUtils.delay(config.integrationTest.wsUpdateDelay);
85+
await TestUtils.delay(testConfig.wsUpdateDelay);
8686
}
8787

8888
/**

__tests__/integration/utils/wallet-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { loggers } from '../txLogger';
22
import { TestUtils, WALLET_CONSTANTS } from './test-utils-integration';
3-
import config from '../../../src/config';
3+
import testConfig from '../configuration/test.config';
44

55
/**
66
* A helper for testing the wallet
@@ -96,7 +96,7 @@ export class WalletHelper {
9696

9797
// Enters the loop checking each wallet for its status
9898
const timestampStart = Date.now().valueOf();
99-
const timestampTimeout = timestampStart + config.integrationTest.walletStartTimeout;
99+
const timestampTimeout = timestampStart + testConfig.walletStartTimeout;
100100
while (true) {
101101
const pendingWalletIds = Object.keys(walletsPendingReady);
102102
// If all wallets were started, return to the caller.

config.js.template

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ module.exports = {
4040
},
4141
*/
4242

43-
// Integration test configs
44-
integrationTest: {
45-
logOutputFolder: 'tmp/', // Should match .github/workflows/integration-test.yml -> upload-artifact
46-
consoleLevel: 'silly',
47-
wsUpdateDelay: 1000,
48-
walletStartTimeout: 60000,
49-
},
50-
5143
// Optional config so you can set the token you want to use in this wallet
5244
// If this parameter is set you don't need to pass your token when getting balance or sending tokens
5345
tokenUid: '',

0 commit comments

Comments
 (0)