From c68f30cf991b3eca16ea8ea6111c6560854e7f33 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 16 Aug 2020 05:17:20 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- package.json | 2 +- test.js | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7df4db9..6718c57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-test", - "version": "1.3.2", + "version": "1.3.3", "description": "experimental test runner....", "main": "test.js", "bin": { diff --git a/test.js b/test.js index 3caa69e..d8ecd18 100644 --- a/test.js +++ b/test.js @@ -11,6 +11,7 @@ (function(require){ var module={} // make module AMD/node compatible... /*********************************************************************/ +var path = require('path') var colors = require('colors') var glob = require('glob') @@ -542,7 +543,7 @@ argv.Parser({ if(!/.*\.js$/.test(path)){ throw argv.ParserError( `${key}: only support .js modules, got: "${path}"`) } - console.log('found module:', path) + console.log('Loading module:', path) // XXX should we handle the load error here??? that.test_modules[path] = require(process.cwd() +'/'+ path.slice(0, -3)) }) }) }}, @@ -611,13 +612,18 @@ function(default_files, tests){ tests = default_files default_files = undefined } + // patch require.cache to make the clients load the global module... + var local = path.join(process.cwd(), 'node_modules', 'ig-test', 'test.js') + require.cache[local] = require.cache[require.main.filename] + var stats = {} - var tests = tests || { - setups: Setups, - modifiers: Modifiers, - tests: Tests, - cases: Cases, - } + var tests = tests + || { + setups: Setups, + modifiers: Modifiers, + tests: Tests, + cases: Cases, + } var p = Object.assign( Object.create(parser), tests,