Giter VIP home page Giter VIP logo

Comments (16)

calvintwr avatar calvintwr commented on May 31, 2024 6

I think it has to do with the CommonJS and ES6 module issues.

Jest is trying to transpile the mjs files but not able to do it correctly. We were able to fix this by directing Jest to use the cjs files:

try this in your jest.config.js:

    moduleNameMapper: {
        '@master-chief/alpaca': '<rootDir>/node_modules/@master-chief/alpaca/dist/cjs/index.cjs',
    },

from alpaca-ts.

117 avatar 117 commented on May 31, 2024 2

Apologies, still haven't had time to circle back to this.

from alpaca-ts.

calvintwr avatar calvintwr commented on May 31, 2024 2

@117 hey nico much thanks. It's very nice of you to credit. If I may could you help to credit @wailinkyaww as well? We found the solution together.

P.S However the underlying issue is not really resolved, but I guess we can go with this. I met similar problems with my repos. I just ditched the whole cjs and mjs altogether, and output a commonJS distro that is compatible with both require and import interfaces:

calvintwr/not@6ce195d

from alpaca-ts.

117 avatar 117 commented on May 31, 2024 1

@117 hey nico much thanks. It's very nice of you to credit. If I may could you help to credit @wailinkyaww as well? We found the solution together.

P.S However the underlying issue is not really resolved, but I guess we can go with this. I met similar problems with my repos. I just ditched the whole cjs and mjs altogether, and output a commonJS distro that is compatible with both require and import interfaces:

calvintwr/not@6ce195d

Added. This issue has been an enigma to me for months! Thank you both, I'm glad we have at least a client-side solution to direct people to now. :)

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

This is so odd, I've used ts-jest and mocked the AlpacaClient itself in my own projects with no issue before. Now I can't seem to find a configuration that works.

from alpaca-ts.

neeschit avatar neeschit commented on May 31, 2024

I spent quite a while trying to figure out where the breakage is, but I'm totally stumped right now

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

When I have free time I'm going to keep looking into resolving this.

from alpaca-ts.

kevindra avatar kevindra commented on May 31, 2024

I also started getting this #77 . It's a bummer as it's failing all other tests when I use this library.
I tried Jest's config to include library.. but didn't help..

module.exports = {
  ...
  transformIgnorePatterns: ["<rootDir>/node_modules/(?!@master-chief/alpaca)"],
};

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

@kevindra I've done some research into it across other related issues on GitHub, could not find a way to get it behaving nicely across the board. Open to ideas though.

from alpaca-ts.

kevindra avatar kevindra commented on May 31, 2024

Thanks! I've switched to mocha and sinon now. No issues there. Spend few hours fixing this issue but couldn't so had to make this call. 🙂

from alpaca-ts.

reessm01 avatar reessm01 commented on May 31, 2024

Hello, I am experiencing this as well.

I want to keep this issue fresh as this is a great solution I hope not to have to depart from!

I have not yet come up with anything, but I'll report back if I do. I've got some old projects on a retired machine that might have some answers. We shall see...

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

Hello, I am experiencing this as well.

I want to keep this issue fresh as this is a great solution I hope not to have to depart from!

I have not yet come up with anything, but I'll report back if I do. I've got some old projects on a retired machine that might have some answers. We shall see...

It's a tough one, any help appreciated 🙏.

from alpaca-ts.

reessm01 avatar reessm01 commented on May 31, 2024

No luck.

In the meantime, I am using jest's mocks for the library, which is good for my needs (primarily boundary testing). I normally achieve that via spies and forget about it.

I am admittedly perplexed by this issue. It may be something I circle back to, but I've got my own problems to solve and need to keep at it. I'll stay tuned though.

Thanks for the prompt replies and attention!

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

I totally get it, same situation here. I've spent hours digging to solve it and it's still an enigma.

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

I think it has to do with the CommonJS and ES6 module issues.

Jest is trying to transpile the mjs files but not able to do it correctly. We were able to fix this by directing Jest to use the cjs files:

try this in your jest.config.js:

    moduleNameMapper: {
        '@master-chief/alpaca': '<rootDir>/node_modules/@master-chief/alpaca/dist/cjs/index.cjs',
    },

I just tested this locally.... it works. Thank you!

from alpaca-ts.

117 avatar 117 commented on May 31, 2024

I've added your snippet to the README, https://github.com/117/alpaca#common-issues.

from alpaca-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.