PatrickAlphaC / hardhat-smartcontract-lottery-fcc

MIT License
117 stars 183 forks source link

require() of ES Module error in hh test #202

Open dashDebasis123 opened 5 months ago

dashDebasis123 commented 5 months ago

I got this error while testing the smart contract. Please help me out.

@PatrickAlphaC

image

borailci commented 5 months ago

What is your Chai version? I had the same error, and when I checked my chai version, I saw that it is above 5. I guess Chai versions above 5 does not support require("chai"). Can you try to downgrade your Chai if it is above 5? You can use : yarn add --dev chai@4.2

cromewar commented 5 months ago

@dashDebasis123 Were you able to solve this?

rocco1226 commented 5 months ago

Chai seems to be updated to ES Modules, which using import() instead of require(). And I did some searches. And the information indicated that ES Modules is the future module system of Node.js and brower. However, it is seemingly not recommended that using both ES Modules and CommonJS Modules. You can use some old versions chai just for study.