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

TypeScript not recognising global variables from tests setup

$
0
0

I am appending some common functions to the global object in my setupTests.ts so I don't need to import them in every test file. The tests are passing, but TypeScript autocompletion is not working and VSCode shows "Cannot find name ...". How can I fix it?

package.json

"jest": {"preset": "jest-expo","roots": ["<rootDir>/src"  ],"setupFiles": ["<rootDir>/src/config/setupTests.ts"  ]}

setupTests.ts

import React from 'react';import { render } from 'react-native-testing-library';global.React = React;(global as any).render = render;

some.test.tsx

const wrapper = render(<Text>Some test</Text>);

enter image description here


Viewing all articles
Browse latest Browse all 6213

Trending Articles



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