LoginSignup
0
0

Error: You must provide the URL of lib/mappings.wasmエラーが出た場合の対応

Last updated at Posted at 2022-08-09

jestでテストを実行したら、下記のエラーが。

Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer

You must provide the URL of lib/mappings.wasm by calling `SourceMapConsumer.initialize` · Issue #35607 · gatsbyjs/gatsbyによればNode.jsのバージョンに起因する問題のようです。ちなみエラーが出た時にはv18.7.0を使っていました。

解決策1

ということでv16にすると正常に終了します。

% npm run test         

> blastengine@1.2.3 test
> jest

 PASS  tests/transaction.test.ts
 PASS  tests/bulk/bulk.test.ts
------------------------------------|---------|----------|---------|---------|------------------------------------------
File                                | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                        
------------------------------------|---------|----------|---------|---------|------------------------------------------
All files                           |   82.74 |    69.76 |   77.41 |   82.74 |                                          
 src                                |     100 |       50 |     100 |     100 |                                          
  index.ts                          |     100 |       50 |     100 |     100 | 21-22                                    
 src/libs                           |   59.03 |     62.5 |   66.66 |   59.03 |                                          
  request.ts                        |   59.03 |     62.5 |   66.66 |   59.03 | 8,18,25-29,38-40,43-45,51-56,66-76,79-82 
 src/libs/delivery                  |   73.33 |      100 |       0 |   73.33 |                                          
  index.ts                          |   73.33 |      100 |       0 |   73.33 | 9-10,13-14                               
 src/libs/delivery/transaction      |   90.58 |       90 |   81.81 |   90.58 |                                          
  base.ts                           |   88.46 |      100 |   71.42 |   88.46 | 34-36,44-46                              
  index.ts                          |   93.93 |       80 |     100 |   93.93 | 10-11                                    
 src/libs/delivery/transaction/bulk |   91.66 |    69.23 |      90 |   91.66 |                                          
  index.ts                          |   91.66 |    69.23 |      90 |   91.66 | 17-23,55                                 
------------------------------------|---------|----------|---------|---------|------------------------------------------

Test Suites: 2 passed, 2 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        3.577 s, estimated 4 s
Ran all test suites.

解決策2

NODE_OPTIONS=--no-experimental-fetch を付けても大丈夫なようです。ただ、おそらくNode.js v18以降のfetchが使えなくなる模様(個人的にはnode-fetchを使っているので良いのですが)。

NODE_OPTIONS=--no-experimental-fetch npx jest
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0