Skip to content

Commit 72f8898

Browse files
committed
refactor: logs folder now fetched from config file
Note: When on Github, the config "outputFolder" property should match the one specified on the integration-test.yml workflow. Otherwise, the test artifacts will not be correctly uploaded
1 parent e6dc2e4 commit 72f8898

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

__tests__/integration/configuration/config.js.template

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

49+
// Integration test transaction logging
50+
integrationTestLog: {
51+
outputFolder: 'tmp/', // Should match .github/workflows/integration-test.yml -> upload-artifact
52+
},
53+
4954
// Optional config so you can set the token you want to use in this wallet
5055
// If this parameter is set you don't need to pass your token when getting balance or sending tokens
5156
tokenUid: '',

__tests__/integration/txLogger.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,26 @@ export class TxLogger {
4040
*/
4141
constructor(title) {
4242
const date = new Date();
43+
44+
/**
45+
* Timestamp in a format like "20220224T084737" for easy human reading on a filename
46+
* @type {string}
47+
*/
4348
const humanReadableTimestamp = date.toISOString()
4449
.replace(/-/g, '') // Remove date separator
4550
.replace(/:/g, '') // Remove hour separator
4651
.split('.')[0]; // Get only the seconds integer
52+
4753
const additionalTitle = title ? `-${title}` : '';
4854
const filename = `${humanReadableTimestamp}${additionalTitle}-integrationTest.log`;
4955
this.#instanceFilename = filename;
5056
}
5157

5258
/**
5359
* Initializes the helper with a winston logger instance
54-
* @returns {Promise<void>}
60+
* @returns {void}
5561
*/
56-
async init() {
62+
init() {
5763
this.#logger = winston.createLogger({
5864
defaultMeta: { service: 'txLogger' },
5965
transports: [
@@ -69,7 +75,7 @@ export class TxLogger {
6975
winston.format.timestamp(),
7076
winston.format.prettyPrint()
7177
),
72-
filename: `tmp/${this.#instanceFilename}`,
78+
filename: `${config.integrationTestLog.outputFolder}${this.#instanceFilename}`,
7379
level: config.consoleLevel || 'silly',
7480
colorize: false,
7581
})

setupTests-integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ beforeAll(async () => {
1919
// Initializing the Transaction Logger with the test name
2020
const testName = getTestNameFromGlobalJasmineInstance();
2121
const testLogger = new TxLogger(testName);
22-
await testLogger.init(__dirname);
22+
testLogger.init();
2323
loggers.test = testLogger;
2424

2525
await TestUtils.startWallet(WALLET_CONSTANTS.genesis);

0 commit comments

Comments
 (0)