Skip to content

Commit 4236f1a

Browse files
committed
fix test
1 parent d2eded9 commit 4236f1a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
1+
/* eslint-disable no-underscore-dangle */
12
require('@babel/register')({
23
// This will override `node_modules` ignoring - you can alternatively pass
34
// an array of strings to be explicitly matched or a regex / glob
45
ignore: [
56
/node_modules\/(?!react-leaflet|@babel\/runtime\/helpers\/esm|lodash-es|@digitransit-util|@digitransit-component)/,
67
],
78
});
9+
10+
// Prevent Node.js from trying to parse CSS files as JavaScript
11+
require.extensions['.css'] = () => {};
12+
13+
// Stub out @hsl-fi packages that are ESM-only — they can't be require()'d by
14+
// Node's CJS loader (ERR_REQUIRE_ESM). Unit tests don't need the real
15+
// implementations; stubs are sufficient for shallow rendering.
16+
const Module = require('module');
17+
18+
const originalLoad = Module._load;
19+
Module._load = function hslFiStub(...args) {
20+
const [request] = args;
21+
if (request.startsWith('@hsl-fi/')) {
22+
return new Proxy(
23+
function StubComponent() {
24+
return null;
25+
},
26+
{
27+
get(target, prop) {
28+
if (prop === '__esModule') {
29+
return true;
30+
}
31+
if (prop === 'default') {
32+
return target;
33+
}
34+
return function StubComponent() {
35+
return null;
36+
};
37+
},
38+
},
39+
);
40+
}
41+
return originalLoad.apply(this, args);
42+
};

0 commit comments

Comments
 (0)