zhuker / lamejs

mp3 encoder in javascript
Other
820 stars 200 forks source link

ReferenceError: Lame is not defined #58

Closed ReneLems closed 5 years ago

ReneLems commented 5 years ago

I import this library with ES6 like this

import lamejs from 'lamejs';

Im using webpack and babel to compile my ES6 code, this all works fine. But when I run my Mocha tests i run into the following error:

node_modules/lamejs/src/js/index.js:19
Lame = require('./Lame.js');
     ^

ReferenceError: Lame is not defined

Shouldn't the following classes be defined as a variable?

Lame = require('./Lame.js');
Presets = require('./Presets.js');
GainAnalysis = require('./GainAnalysis.js');
QuantizePVT = require('./QuantizePVT.js');
Quantize = require('./Quantize.js');
Takehiro = require('./Takehiro.js');
Reservoir = require('./Reservoir.js');
MPEGMode = require('./MPEGMode.js');
BitStream = require('./BitStream.js');

I'll make a PR for this, but please let me know if I'm missing something

ReneLems commented 5 years ago

Nevermind, I now see that i needed to mock this package. Also instantiating these as variables gives other errors. I'm going to close this issue. Sorry for the unnecessary issue

YannicEl commented 5 years ago

@ReneLems How did you fix the problem?

wasimafsar commented 4 years ago

@ReneLems How did you fix the problem?

MooseSaeed commented 2 years ago

@ReneLems I wish you could just tell us how did you fix it

rlems commented 2 years ago

@MooseSaeed I mocked the Lame service, since the error only occurred for me while testing with Mocha. Didn't need to fix the issue this way. If the error occurs for you during testing as well, then you can also mock Lame, otherwise I can't help you.