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

add jest dom dependency #220

Merged
merged 1 commit into from
Mar 28, 2023
Merged

add jest dom dependency #220

merged 1 commit into from
Mar 28, 2023

Conversation

just-boris
Copy link
Member

Description

I am planning some refactoring in #219 and this needs better assertions in tests.

Also I found that our previous tsconfig ignored *.test.ts files, so fixed this and all new discovered type errors

Related links, issue #, if available: n/a

How has this been tested?

PR build

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


// type-only import, because in runtime it tries to access Jest globals, which do not exist
/// <reference types="@testing-library/jest-dom" />
import matchers from "@testing-library/jest-dom/matchers";
Copy link
Member Author

Choose a reason for hiding this comment

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

Followed example setup from this thread: testing-library/jest-dom#439

@@ -11,5 +11,5 @@
"experimentalDecorators": true,
"tsBuildInfoFile": "../../.cache/test-utils.tsbuildinfo"
},
"include": ["./", "../../types"]
"include": ["./", "./types"]
Copy link
Member Author

Choose a reason for hiding this comment

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

Created separate *.selectors.js type declarations for test-utils folder, because there is a difference between "module": "CommonJS" (used for compilation) and "module": "ESNext", (used in tests)

import { ScreenshotPageObject } from "@cloudscape-design/browser-test-tools/page-objects";
import { expect, test } from "vitest";
import { routes } from "../../pages/pages";
Copy link
Member Author

@just-boris just-boris Mar 24, 2023

Choose a reason for hiding this comment

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

Removed import across sub-projects to prevent e2e tests importing pages code in tests scope

@@ -5,7 +5,7 @@
"target": "ES2019",
"jsx": "react-jsx",
"types": [],
"lib": ["es2019", "dom"],
"lib": ["es2019", "dom", "dom.iterable"],
Copy link
Member Author

Choose a reason for hiding this comment

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

To support [...document.querySelector()] pattern, which we use a lot in the tests. This works in all our supported browsers

},
"include": ["types", "**/*.test.tsx"],
Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Because *.ts was missing here, all such tests were not checked. It is recommended to put just folder paths (supported extensions will be added automatically)

@codecov
Copy link

codecov bot commented Mar 24, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (167acfe) 93.96% compared to head (0406fbb) 93.97%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #220   +/-   ##
=======================================
  Coverage   93.96%   93.97%           
=======================================
  Files          15       16    +1     
  Lines         729      730    +1     
  Branches      178      178           
=======================================
+ Hits          685      686    +1     
  Misses         38       38           
  Partials        6        6           
Impacted Files Coverage Δ
src/__tests__/setup.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


export const pages = Object.keys(pagesRaw).map(getPage);
export const routes = pages.map(getRoute);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is e2e-only export, extracted separately now

@just-boris just-boris marked this pull request as ready for review March 24, 2023 13:49
@just-boris just-boris requested a review from a team as a code owner March 24, 2023 13:49
@just-boris just-boris requested review from avinashbot, a team and abdhalees and removed request for a team and avinashbot March 24, 2023 13:49
Copy link
Member

Choose a reason for hiding this comment

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

this file is missing the copyright banner

Copy link
Member

Choose a reason for hiding this comment

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

this file is missing the copyright banner

Copy link
Member Author

Choose a reason for hiding this comment

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

These are JSON files, so adding comments is not possible there.

This is a known exception, same treatment can be found in the main repo: https://github.com/cloudscape-design/components/blob/main/tsconfig.json

@just-boris just-boris merged commit 16d8029 into main Mar 28, 2023
@just-boris just-boris deleted the add-jest-dom branch March 28, 2023 11:44
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.

2 participants