Hook require to prevent tests failures when loading images
This commit is contained in:
parent
7cc3918b8d
commit
b2daaa2159
|
@ -55,6 +55,7 @@
|
||||||
:output-to "target/test/test.js"
|
:output-to "target/test/test.js"
|
||||||
:output-dir "target/test"
|
:output-dir "target/test"
|
||||||
:optimizations :none
|
:optimizations :none
|
||||||
|
:preamble ["js/hook-require.js"]
|
||||||
:target :nodejs}}
|
:target :nodejs}}
|
||||||
{:id "protocol"
|
{:id "protocol"
|
||||||
:source-paths ["src" "test/cljs"]
|
:source-paths ["src" "test/cljs"]
|
||||||
|
|
|
@ -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);
|
||||||
|
};
|
|
@ -1,5 +0,0 @@
|
||||||
(ns status-im.utils.ethereum.tokens)
|
|
||||||
|
|
||||||
(def ethereum {})
|
|
||||||
|
|
||||||
(def all {})
|
|
Loading…
Reference in New Issue