Comments (16)
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.
Apologies, still haven't had time to circle back to this.
from alpaca-ts.
@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:
from alpaca-ts.
@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:
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.
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.
I spent quite a while trying to figure out where the breakage is, but I'm totally stumped right now
from alpaca-ts.
When I have free time I'm going to keep looking into resolving this.
from alpaca-ts.
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.
@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.
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.
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.
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.
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.
I totally get it, same situation here. I've spent hours digging to solve it and it's still an enigma.
from alpaca-ts.
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.
I've added your snippet to the README, https://github.com/117/alpaca#common-issues.
from alpaca-ts.
Related Issues (20)
- News Support HOT 3
- CORS Paper mode issue? HOT 5
- Streaming using Paper Credentials HOT 3
- V2 Market Data Additions HOT 7
- Support for overriding baseUrls HOT 6
- Does not compile with TypeScript 4.7 module = nodenext HOT 26
- BarsTimeframe not supporting arbitrary values HOT 4
- Cannot run npm run build with node v17 & npm v8 HOT 1
- Bar interface does not match Alpaca Bar HOT 10
- Package does not export typing information
- Add `non_marginable_buying_power` to the `getAccount` response.
- Create Account Endpoint
- What would be the best way to get previous trading history for an account?
- Uncaught (in promise) Error: PageOfTrades parsing failed "Cannot read property 'map' of null" HOT 2
- Error: export 'AlpacaClient' (imported as 'AlpacaClient') was not found in '@master-chief/alpaca' (possible exports: default) HOT 2
- /v2/positions/{symbol} supports qty and percentage params HOT 1
- Expand timeframe options for getBars HOT 2
- Crypto Support HOT 10
- Add Functionality to Close AlpacaStream? HOT 2
- Build Output Not Reflecting Recent PR HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alpaca-ts.