Comments (9)
Also not working on Picker from @react-native-community/picker
picker props = {
testID: 'picker',
style: [ { height: 216 }, undefined ],
items: [
{ value: 'USD', label: 'USD', textColor: undefined },
{ value: 'LKR', label: 'LKR', textColor: undefined }
],
selectedIndex: 0,
onChange: [Function],
children: undefined
}
it('should change the selected index when changed', () => {
const { getByTestId } = setup();
const picker = getByTestId(testIds.picker);
console.log('picker props = ', picker.props);
expect(picker).toHaveProp('selectedIndex', 0);
fireEvent(picker, 'onValueChange', 'LKR');
expect(picker).toHaveProp('selectedIndex', 3);
});
The tests always pass regardless of what I'm passing as the prop value.
from jest-native.
I'll try to spare some time to help you guys. Do you have any suggestions in mind to fix that? If so, feel free to open a PR.
from jest-native.
@mdjastrzebski anything changing from RNTL side provided this PR you recently contributed? callstack/react-native-testing-library#460
from jest-native.
I'll try to reproduce it with TL/RN v7.
from jest-native.
i'm experiencing this too.
using these versions:
"@testing-library/jest-native": "^3.3.0",
"@testing-library/react-native": "^7.0.2",
"react-test-renderer": "16.6.3"
i see there's a flag called isAllowed
in this function (toHaveProp), if it's false, the value check is ignored and it passes if the prop exists.
it seems to be false if the element is not in a 'valid_elements' list (don't understand why it's necessary), the issue in my case is:
this is the row to determine the flag value:
var isAllowed = _utils.VALID_ELEMENTS.includes(element.type);
-> to-have-prop.js : 27
but VALID_ELEMENTS
is a list of strings (components names) and element.type
is a component instance, with a property displayName
that suits this list. if i change your code to:
var isAllowed = _utils.VALID_ELEMENTS.includes(element.type.displayName);
, is works fine.
also maybe i miss something but i don't understand why there are components that aren't allowed to have their props checked for values? (what is the meaning of that flag?)
from jest-native.
i now see it happens for me when i get the ReactTestInstance using getByText
accessor,
and if i'm using getByTestId
it returns a ReactTestInstance with a slightly different structure, with type
property as string, and in this case toHaveProps
works great.
maybe it's possible to add a check for the type of type
property in the TestInstance?
from jest-native.
This one should be resolved by #36
from jest-native.
Still having this issue with version 3.4.3
and TouchableOpacity
.
expect(getByTestId('test_id_test')).toHaveProp('disabled')
from jest-native.
Anyone having a solution to this? A test just randomly start failing which uses toHaveProp
from jest-native.
Related Issues (20)
- ToBeEmpty assertion in jest-native is also used in jest-extended HOT 2
- toHaveStyle breaks if style is a nested array HOT 2
- Matcher toBeDisabled does not take into account the editable prop of TextInput HOT 3
- Missing (dist) index.js which exports all matchers for library usage HOT 4
- toBeVisible failing when used on Pressable with style function HOT 1
- Property 'toHaveTextContent' does not exist on type 'Matchers<void> & ...' (and any other matcher from library) HOT 15
- Add toBeOnTheScreen matcher to src/index exports HOT 2
- toBeOnTheScreen() not Working With React-Native HOT 5
- toBeEmptyElement isn't working as expected HOT 2
- Peer dependency error after upgrading React to 18.1.0 HOT 5
- Property 'toBeOnTheScreen' does not exist on type 'JestMatchers<ReactTestInstance>' (TS project) HOT 20
- toHaveAccessibilityValue always truthy HOT 4
- toBeVisible ignores opacity via color property HOT 2
- Using toBeOnTheScreen() matcher requires @testing-library/react-native v10.1.0 or later to be added to your devDependencies HOT 2
- Property 'toHaveTextContent' does not exist on type 'JestMatchers<ReactTestInstance | null>'.ts(2339) HOT 2
- Cerate an eslint plugin to sudgest to use alternative jest matchers. HOT 2
- "SyntaxError: Cannot use import statement outside a module" after upgrading to react-native 0.72.4 HOT 3
- Add support for aria properties HOT 1
- refactor: migrate code to TypeScript HOT 1
- refactor: remove Ramda dependency HOT 1
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 jest-native.