New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type check test files #5626
Comments
Check out your Change this to an empty array if you want to include them
|
the types are checked in the |
This is currently a known limitation. We can check these types in the future. For now, please rely on VSCode to type check your tests or run |
Another option, update your test scripts to run Update your - "test": "react-scripts test",
+ "test": "tsc && react-scripts test", The Additional Optional SolutionsIf you have a different testing script for "test:ci": "CI=true tsc && react-scripts test --env=jsdom --coverage", If you're using
|
We can also use |
The future of |
This is also happening to me. Any updates? |
- Invoke TSLint - Invoke tsc to type-check tests (facebook/create-react-app#5626)
FYI: kulshekhar/ts-jest#1549 will be in alpha version of ts-jest (possibly today). You can test the alpha version and give some feedbacks for kulshekhar/ts-jest#1115 |
* GCW-3432 Remove routing logic * GCW-3432 Create component for main routing Essential for testing routing by allowing us to mock router history * GCW-3432 Move MainRouter to its own directory * GCW-3432 Test for presence of ion-router-outlet Ionic uses this to handle animations related to navigation/routing * GCW-3432 Move router outlet to MainRouter Component required by Ionic so rather not have to mock this out in tests * GCW-3432 Install history * GCW-3432 Test navigation to /home url * GCW-3432 Use Router instead of IonReactRouter Components do not show up as expected on JSDOM with IonReactRouter * GCW-3432 Show the home page * GCW-3432 Create login page and routing * GCW-3432 Refactor tests * GCW-3432 Remove test in incorrect location Test belongs to MainRouter * GCW-3432 Add missing assertion in test * GCW-3432 Add assertion for ion-router-outlet * GCW-3432 Make assertions more explicitly * GCW-3432 Create context for authentication state * GCW-3432 Route users based on auth state * GCW-3432 Downgrade history version Latest version has compatibility issues esp. redirects * GCW-3432 Test redirect normally without spyOn Reverting history ver. to 4 fixes the issue with redirects * GCW-3432 Redirect user from root path Routing should be based on user auth status * GCW-3432 Add title to login page * GCW-3432 Test without resorting to data-testid Rely on actual DOM elements for testing rather than data-testid * GCW-3432 Change file naming convention index.ts convention makes it harder to distinguish tabs in editors * GCW-3432 Put Login into its own folder * GCW-3432 Move MainRouter to components folder * GCW-3432 Create login button * GCW-3432 Simplify test element selectors * GCW-3432 Create login functionality * GCW-3432 Update ion router outlet test Don't rely on data-testid * GCW-3432 Encapsulate auth access in custom hook * GCW-3432 Install TS + add type checking to tests Reference: facebook/create-react-app#5626 * GCW-3432 Encapsulate auth state in Provider * GCW-3432 Update tests to use AuthProvider * GCW-3432 Wrap app with AuthProvider * GCW-3432 Fix type error in test * GCW-3432 Refactor tests * GCW-3432 Refactor test expectations to function * GCW-3432 Refactor tests Change function signature of render function to allow for currying * GCW-3432 Refactor tests * GCW-3432 Route from non-existent page (unauthed) * GCW-3432 Route from non-existent page (authed) * GCW-3432 Remove redundant route * GCW-3432 Handle visiting page with /login prefix * GCW-3432 Handle visiting page with /home prefix * GCW-3432 Encapsulate private route logic * GCW-3432 Refactor login tests * GCW-3432 Redirect user to home on login * GCW-3432 Increase test clarity * GCW-3432 Move expectation fn to test utils
Any update on this point ? |
Neither CRA's build nor test steps do this. Fix various minor typing errors to get this clean again. facebook/create-react-app#5626
Neither CRA's build nor test steps do this. Fix various minor typing errors to get this clean again. facebook/create-react-app#5626
This behavior comes from how Jest runs against typescript. Not really a CRA thing per se, as CRA is just using a relatively vanilla Jest typescript configuration under the hood: https://jestjs.io/docs/getting-started#using-typescript From the Jest docs:
Jest seems to just recommend running |
Bug report
I created a new project with the
--typescript
flag, and added a type for my component's props like so:In index.tsx when I write something like (note the missing prop):
I get an error in both my editor (VSCode) and on my console when I run
yarn start
.However in my tests if I have something like:
I get the type error in my editor but NOT when I run
yarn test
, the tests run successfully in fact.Is this intended?
The text was updated successfully, but these errors were encountered: