Closed g-wozniak closed 4 years ago
Ok, I resolved it. The problem was in placement of the @observer
which is fairly pointed out by warning. I missed the obvious, that decorator "closer" to element (class/component) is the one applied earlier. Once I switched their places it started to show the right value.
Having a simple Locale store: (works in real component)
and trying to test it in Enzyme / TS / React:
It works properly if I want just to render component but my goal here is to use
setLanguage
method to change the default language to a different value.Ideally, I'd like to test if
div.test
is lang1.bar before mount and lang2.bar after mount.I tried the approach with:
shallow()
, thenconst i = comp.instance()
but this returnsnull
shallow().dive()
- didn't helpWhat would be best approach to test this scenario? How would you approach to it?
Note: I've replaced
@observable
(ofc!) with@observer
. I am seeingMobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'
warning regardless the fact@observer
is added before inject.