UNPKG

jupyter-js-auto-test

Version:

Auto scan files under the directory and run test in them

59 lines (50 loc) 1.24 kB
const chalk = require('chalk') const { TestFunctionConfig, readConfigAndRun } = require('../index') module.exports = { foo, foo2, foo3 } function foo(callback) { if (1 + 1 === 2) { console.log(chalk.green('Test foo passed')) callback(true) } else { console.log(chalk.red('Test foo failed due to '), 'impossible') callback(false, 'error message') } } const obj = { foo2: (callback) => { if (1 + 1 === 2) { console.log("Object run foo2") callback(null) } else { console.log("Object run foo2") callback("impossible") } } } function foo2(callback) { readConfigAndRun( new TestFunctionConfig(obj, 'foo2', [], null), callback ) } function foo3(callback) { readConfigAndRun( new TestFunctionConfig(null, abc), callback ) } function abc(callback) { // (callback) => { // } if (1 + 1 === 2) { console.log("Function test foo3 passed") callback(null) } else { console.log("Function test foo3 failed") callback("impossible") } }