elbywan / wretch

A tiny wrapper built around fetch with an intuitive syntax. :candy:
MIT License
4.79k stars 96 forks source link

unable to find module `wretch/addons/abort` in jest #144

Closed th3fallen closed 2 years ago

th3fallen commented 2 years ago

For some reason when i run any tests I'm unable to resolve anything from the addons dir? any ideas?

elbywan commented 2 years ago

Hey @th3fallen,

For some reason when i run any tests I'm unable to resolve anything from the addons dir? any ideas?

You could try to update jest to the latest version I guess (jest@29).

I tried to setup a bare project with jest and it seems to work fine on my end.

mkdir test-wretch-jest
cd test-wretch-jest
npm i wretch jest
# Write the test
echo "const abort = require('wretch/addons/abort');
test('require from addons', () => {
  expect(abort).toBeDefined()
  console.log(abort)
});" > test.js
# Run it
./node_modules/.bin/jest

Output:

❯ ./node_modules/.bin/jest
  console.log
    [Function (anonymous)]

      at Object.log (test.js:4:11)

 PASS  ./test.js
  ✓ require from addons (14 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.337 s, estimated 1 s
Ran all test suites.

Closing the issue since I'm pretty sure the problem is not related to wretch itself.