Skip to content
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

Tests pass even when there are TypeScript errors #851

Closed
darrenvong opened this issue Mar 24, 2021 · 7 comments · Fixed by #1089
Closed

Tests pass even when there are TypeScript errors #851

darrenvong opened this issue Mar 24, 2021 · 7 comments · Fixed by #1089
Assignees
Labels

Comments

@darrenvong
Copy link
Member

darrenvong commented Mar 24, 2021

According to facebook/create-react-app#5626, there's a limitation in how Create React App sets out jest, which means type checking isn't being done properly on test files. That means tests could still be passing even if they should break because of TS error.

The workaround seems to be adding tsc before running the tests so the test files goes through the TS type checker and only run the tests if succeeds. Will have to fix some broken test files as a result of this.

Also, linting also don't seem to be applied to test files which would normally fail the app build, so we may need to add a similar workaround to the above by running the eslint command against files ending in test.ts[x]*.

@darrenvong darrenvong changed the title Tests doesn't fail even when there's TypeScript errors Tests pass even when there's TypeScript errors Mar 24, 2021
@darrenvong darrenvong changed the title Tests pass even when there's TypeScript errors Tests pass even when there are TypeScript errors Mar 24, 2021
@lucaslcode
Copy link
Member

Is this why tests are passing CI but failing locally?

@darrenvong
Copy link
Member Author

No don't think so, that's a separate issue. I think the tests failing locally is something weird with the mocks not working again... not sure why CI likes the workaround but not our machine locally sometimes 🤷

This is more to do with the fact if you add a new prop to a component and you don't update the tests, sometimes it stills passes (when it should fail like in the main app)

@thdk
Copy link
Member

thdk commented Apr 10, 2021

Hi everyone! I would love to pick up this issue (and join the development team if I may :) ).

@lucaslcode
Copy link
Member

Assigned! Also send me an email (address on my profile)

@darrenvong
Copy link
Member Author

One other thing I forgot to write in the first description, can you also look at linting the test files too while you are in the area please? I think these are all related enough issues that it'd be good to fix them together. Apologies if that might mean more files to fix 😬

@thdk
Copy link
Member

thdk commented Apr 10, 2021

No worries, I've jest setup my dev environment so I can start working.

Do you mean these two lint warnings?

image

@darrenvong
Copy link
Member Author

Do you mean these two lint warnings?

image

Yup! Looks like there aren't too many then 😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants