Hook require to prevent tests failures when loading images

This commit is contained in:
Julien Eluard 2017-11-29 16:31:15 +01:00 committed by Julien Eluard
parent 7cc3918b8d
commit b2daaa2159
3 changed files with 15 additions and 5 deletions

View File

@ -55,6 +55,7 @@
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:preamble ["js/hook-require.js"]
:target :nodejs}}
{:id "protocol"
:source-paths ["src" "test/cljs"]

View File

@ -0,0 +1,14 @@
const m = require('module');
const originalLoader = m._load;
/*
Hook `require` so that RN abuse of require does not break when running tests in nodejs.
*/
m._load = function hookedLoader(request, parent, isMain) {
if (request.match(/.jpeg|.jpg|.png$/)) {
return { uri: request };
}
return originalLoader(request, parent, isMain);
};

View File

@ -1,5 +0,0 @@
(ns status-im.utils.ethereum.tokens)
(def ethereum {})
(def all {})