File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* eslint-disable no-underscore-dangle */
12require ( '@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 / n o d e _ m o d u l e s \/ (? ! r e a c t - l e a f l e t | @ b a b e l \/ r u n t i m e \/ h e l p e r s \/ e s m | l o d a s h - e s | @ d i g i t r a n s i t - u t i l | @ d i g i t r a n s i t - c o m p o n e n t ) / ,
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+ } ;
You can’t perform that action at this time.
0 commit comments