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

Include typechecking for all files in the CI #571

Merged
merged 19 commits into from
Dec 29, 2021
Merged

Conversation

lomky
Copy link
Contributor

@lomky lomky commented Dec 2, 2021

Changes in this PR!

  • Adds the typescript build to our CI, so that all files are typecheckd
  • Adds the missing types for jest with the @types/jest plugin
  • Corrects all ~100 type errors in our tests. Types of corrections include:
    • Actual type fixes
      • see return type in Appointment.test.tsx as an example
      • see proper parameters in Header.test.tsx as an example
    • More explicit types, to help the TS compiler
      • see the types for objects passed to describe.each loops
    • Adding ? to checks where the base object could be undefined
      • Many places. i.e. element?.tagName.toLowerCase() === 'strong' in TransLine.test.tsx
    • Added type narrowing to assert the object is not undefined for assertions to use
      • See apiGatewayStub.test.ts if it does return undefined it should throw a failure
    • Explicit as unknown, as string overrides to test unexpected, mistyped values
      • See getScenarioContent.test.ts as example
    • Explicitly casts IncomingMessage in queryApiGateway.test.ts, to avoid a huge mock
  • Adds two TS overrides for now, for places that may involve code changes. Will file tickets for these.
    • tests/pages/indexServerSide.test.ts - nextJS & typescript cannot agree on typing.
    • tests/utils/apiGatewayStub.test.ts - mocking for fs, fetch & typescript do not agree on typing
  • Moves the getUrl.test.ts to a matching subdir to its utility

TK: tickets for resolving overrides:

===

Resolves #444

  • Tests that fall out of date will alert the dev

@lomky lomky self-assigned this Dec 2, 2021
Copy link
Contributor

@kalvinwang kalvinwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epic, thank you!

@lomky lomky assigned kalvinwang and unassigned lomky Dec 23, 2021
@kalvinwang kalvinwang merged commit af31375 into main Dec 29, 2021
@kalvinwang kalvinwang deleted the kat/444_ts_on_tests branch December 29, 2021 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce Typescript linting & build on test files
2 participants