-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using Typescript / ts-jest transform issue w/ default exports #5303
Comments
and even though that jest tries to get the dist folder, I get the same using the src folder
|
hi there! sorry you're having an issue. as the issue template explains, we require that you provide a runnable example that reproduces the bug on https://snack.expo.io or in a github repository. please try to minimize the superfluous code and focus only on reproducing the bug. you might wonder, why are we strict about this? the reason is that there are only a small number of maintainers on this project and there are hundreds of people who report issues. if it takes us 20 minutes on average to reproduce each issue and we go through 10 issues each day, that's about half of our day just trying to reproduce bugs, without even beginning to investigate solutions. compare that to 20 minutes for each person who reports an issue. please create a new issue with this and i'd be happy to review it! |
Hi @brentvatne I have submitted a reproducible repository in the first comment . Since this is a testing issue I cannot submit a snack |
hey @vincentbriglia - sorry for that. nonetheless we can't help debug issues with configuration like this, you'd be better off asking on ts-jest or some typescript related repository. when you are certain you have found an issue with react-navigation then come here and report precisely what it is :) |
@vincentbriglia Did you find the answer? |
@vincentbriglia did you find any solution? :) |
I didn’t end up finding a solution using ts-jest - we stopped using ts-jest altogether after some other issues and focused instead on using Babel. Not ideal due to its known documented limitations with const enums etc... but we had to move forward |
I'm having the same issue with Typescript and I wonder how did you manage to solve it @vincentbriglia ? Would you be so nice to show me your config?
|
@mtt87 on package.json on jest.transform if you have "^.+\.js$": "/node_modules/react-native/jest/preprocessor.js" try removing it. It worked for me. I followed this thread to find this solution: facebook/react-native#22175 |
This is what I have now and it is working, and yes I also removed that line you mentioned. "jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@react-native-community|react-navigation|react-navigation-tabs|react-navigation-stack|@react-navigation/.*|react-native-svg)"
],
"roots": [
"__tests__",
"__mocks__"
],
"testRegex": "(/__tests__/.*(\\.|/)(test|spec))\\.[jt]sx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFiles": [
"./jest.setup.js"
]
} And this is the jest.mock('react-native-gesture-handler', () => {
const View = require('react-native/Libraries/Components/View/View');
return {
Swipeable: View,
DrawerLayout: View,
State: {},
ScrollView: View,
Slider: View,
Switch: View,
TextInput: View,
ToolbarAndroid: View,
ViewPagerAndroid: View,
DrawerLayoutAndroid: View,
WebView: View,
NativeViewGestureHandler: View,
TapGestureHandler: View,
FlingGestureHandler: View,
ForceTouchGestureHandler: View,
LongPressGestureHandler: View,
PanGestureHandler: View,
PinchGestureHandler: View,
RotationGestureHandler: View,
/* Buttons */
RawButton: View,
BaseButton: View,
RectButton: View,
BorderlessButton: View,
/* Other */
FlatList: View,
gestureHandlerRootHOC: jest.fn(),
Directions: {},
};
});
jest.mock('react-native-reanimated', () => {
const { View } = require('react-native');
return {
Value: jest.fn(),
event: jest.fn(),
add: jest.fn(),
eq: jest.fn(),
set: jest.fn(),
cond: jest.fn(),
interpolate: jest.fn(),
View,
Extrapolate: { CLAMP: jest.fn() },
Transition: {
Together: 'Together',
Out: 'Out',
In: 'In',
},
Easing: {
in: jest.fn(),
out: jest.fn(),
inOut: jest.fn(),
},
};
}); |
@mtt87 for 'react-native-reanimated' you can just use: and for 'react-native-gesture-handler' you can add to your setupFiles section on package.json this: "./node_modules/react-native-gesture-handler/jestSetup.js", |
That's fantastic, even better thank you very much. This is the kind of stuff that it should be on the react navigation website. I will make a PR as soon as I can 😄 |
So TypeScript is not supported? |
uncertain why this is happening, been trying to debug this for some time. repro repository below, have not had any other 3rd party component error out with the same default import in larger projects.
repro here: https://github.com/vincentbriglia/jesttest
Your Environment
OS: macOS Mojave 10.14 (18A391)
The text was updated successfully, but these errors were encountered: