'use strict'; const tests = require('./sum.test'); const { SumTestSuite } = require('./SumTestSuite'); function runTestFile() { const results = {}; Object.entries(tests).forEach( ([_, testData]) => { console.log(testData.description); try { testData.test(); console.log('SUCCESS'); // FIXME no results[testData.description] = null; } catch (err) { console.log('FAILED'); console.log(err.message); results[testData.description] = err; } } ); return results; } function runTestSuite() { const suite = new SumTestSuite(); const suiteProto = Object.getPrototypeOf(suite) const testMethodNames = Object.getOwnPropertyNames(suiteProto).filter( prop => typeof suite[prop] === 'function' && prop.startsWith('test') ); testMethodNames.forEach( testMethodName => { console.log(testMethodName); try { suite[testMethodName](); console.log('SUCCESS'); } catch (err) { console.log('FAILED'); console.log(err.message); } } ); } runTestSuite();