Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

react-native-testing-library working async tests but getting test not wrapped in act warning

$
0
0

hey all I have working tests and I know it wants me to wrap my render in an act but if I do that I get a warning stating it can't find root. yet if I then instead change it to create i can't use my getbyTestId method.

`it('should not render image', async () => {        // Arrange        // needs to be used to support async mounting methods like useeffect/componentdidmount        jest.useFakeTimers();        const testComment = {            text: 'placeholder'        } as WorkItemComment;        await act(async () => {            AsyncStorage.setItem('authMethod', 'msa')        });        const placeholderComment: WorkItemComment = testComment;        const placeholderImage: string = 'image';        // Act        const { queryByTestId } = render(<CommentList workItemComments={[placeholderComment]} profilePicture={[placeholderImage]} />);        // Assert        await wait(() => {            expect(queryByTestId('image')).toBeNull();        })    });`

actual component its rendering and where believe this error is stemming from.

`const fetch = async () => {    const authMethod = await AsyncStorage.getItem('authMethod');    setAuthMethod(authMethod!)  };  useEffect(() => {    fetch();  }, [props.workItemComments]);`

Viewing all articles
Browse latest Browse all 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>