"react": "16.2.0",
"react-native": "0.53.0",
"native-base": "^2.3.7",
The Jest test suite is expected to run & tests pass
TypeError: Cannot read property 'brandPrimary' of undefined
at Object.<anonymous> (node_modules/native-base/src/theme/variables/platform.js:196:20)
at Object.<anonymous> (node_modules/native-base/dist/src/theme/components/Body.js:1:112)
at Object.<anonymous> (node_modules/native-base/src/theme/components/index.js:2:1)
import React, { Component } from 'react';
import { Footer, Text, Left, Body, Right } from 'native-base';
class SimpleComponent extends Component {
render() {
const { leftText, rightText } = this.props;
return (
<Footer>
<Left>
<Text>{leftText}</Text>
</Left>
<Body/>
<Right>
<Text>{rightText}</Text>
</Right>
</Footer>
);
}
}
export default SimpleComponent;
describe('Components | SimpleComponent', function () {
let wrapper;
const leftTest = 'Text';
beforeEach(() => {
wrapper = shallow(<SimpleComponent leftTest={leftTest}/>);
});
it('renders leftText', function () {
expect(wrapper.find(Text).text()).to.eq(leftTest);
});
});
+1
@max-konin Share complete snippet for test case
To solve this issue, just replace this :
radioColor: this.brandPrimary,
by this :
get radioColor() {
return this.brandPrimary;
},
in files native-base-theme/variables/platform.js and native-base-theme/variables/material.js at line 196.
This is due to the fact that you cannot access an object property while declaring it. So, in my solution, i am using a computed property, which will be evaluated at runtime.
I can do a PR if you want.
@thomaswinckell thx, it works for me.
@SupriyaKalghatgi Do you need snippet for test case now?
@SupriyaKalghatgi why is it closed? it still occur with master branch of NativeBase
@max-konin Fixed on branch master
Still seeing the issue at line 196 using "native-base": "^2.3.9", as package.json config.
FAIL __tests__/App.js
โ Test suite failed to run
TypeError: Cannot read property 'brandPrimary' of undefined
at Object.<anonymous> (node_modules/native-base/dist/src/theme/variables/platform.js:196:22)
at Object.<anonymous> (node_modules/native-base/dist/src/theme/components/Body.js:1:174)
at Object.<anonymous> (node_modules/native-base/dist/src/theme/components/index.js:2:11)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.621s
Ran all test suites.
Jest basic test still failing.
@SupriyaKalghatgi nice. thx
@liltimtim #1578 comment
@SupriyaKalghatgi I clicked on your link but it doesn't go anywhere? Not sure what's going on there. I saw you had updated the Master branch and updated the version to 2.3.9 however I was still seeing the issue / no change in that version. Perhaps I'm using an old version?
@liltimtim try to use native-base from master branch. 2.3.9 still has the error
@liltimtim The link i shared above was about comment pointing in this issue itself, which said,
Fixed on branch
master
This issue has been fixed on master and not released with patch 2.3.9
When can we expect the next release?
I'm in a bit of problematic situation, because native-base 2.3.6-2.3.9 has this issue, while 2.3.5 does not. However, 2.3.5 has #1359 for me.
I can't use the package from GitHub for some reason (e.g. I tried using #master and a few other commits):
error: bundling failed: Error: Unable to resolve module `./theme/components` from `<...>/app/node_modules/native-base/dist/src/index.js`: The module `./theme/components` could not be found
@panuhorsmalahti In a day or two
Most helpful comment
@panuhorsmalahti In a day or two