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 test setup for monorepo and example test #25

Merged
merged 5 commits into from
Nov 29, 2021

Conversation

etr2460
Copy link
Contributor

@etr2460 etr2460 commented Nov 29, 2021

I noticed we had no tests, so yarn test was failing (locally at least, in CI it was set to pass with no tests). This PR:

  • adds an example test
  • adds the jest-dom testing library helper functions (documentation here, but i've found them super useful: https://github.com/testing-library/jest-dom)
  • removes the flag in CI to pass without tests (since now we have 1 test!)
  • Moves TS and test infra out of components and into the root of the monorepo (so it can be shared by all packages)

to: @Dhaiwat10 @crondinini

@etr2460 etr2460 force-pushed the erik-ritter--add-example-test branch from 426a22f to 4b0bb0d Compare November 29, 2021 03:07
@Dhaiwat10
Copy link
Member

This is something we absolutely need but I'm afraid you're gonna have to do a small re-factor in order to accomodate the new monorepo structure 😬

@etr2460 etr2460 changed the title Add example test and setupTests.ts Add test setup for monorepo and example test Nov 29, 2021
@etr2460 etr2460 force-pushed the erik-ritter--add-example-test branch from 4b0bb0d to df85949 Compare November 29, 2021 05:06
@etr2460 etr2460 force-pushed the erik-ritter--add-example-test branch from df85949 to 770148f Compare November 29, 2021 05:10
@etr2460
Copy link
Contributor Author

etr2460 commented Nov 29, 2021

@Dhaiwat10 this is now rebased, and makes a couple additional changes to support a monorepo.

cc @crondinini to take a look at the monorepo parts (I think i'm understanding what stuff should be shared vs. split, but would be great to ensure this is following your mental model too)

@etr2460 etr2460 mentioned this pull request Nov 29, 2021
Copy link
Member

@with-heart with-heart left a comment

Choose a reason for hiding this comment

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

Love it!

package.json Outdated
Comment on lines 11 to 13
"test": "jest --maxWorkers=2",
"test:watch": "yarn test --watch",
"test:coverage": "jest --coverage --colors --maxWorkers=2"
Copy link
Member

Choose a reason for hiding this comment

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

We should probably adjust our use of --maxWorkers flags here. 2 is oddly specific and imo doesn't maximize things in our favor: https://dev.to/vantanev/make-your-jest-tests-up-to-20-faster-by-changing-a-single-setting-i36

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i'll remove the flag. wasn't sure why it was set in the first place, but also we have so few tests anyway, it probably doesn't make a difference

Copy link
Contributor

@crondinini crondinini left a comment

Choose a reason for hiding this comment

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

This is great! 🚀

@@ -8,7 +8,15 @@
"pre-commit-hook": "yarn lint-staged",
"format": "prettier --write",
"build": "yarn workspace @web3-ui/components build",
"test": "yarn workspace @web3-ui/components test"
"test": "jest",
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, absolutely, that is what I was thinking about.

],
coveragePathIgnorePatterns: [
"/node_modules/",
"dist/",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we need to ignore dist also from within the packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i believe this will ignore any instance of dist, although i might be wrong. we're not using the coverage stats yet though, so it probably doesn't matter?

coveragePathIgnorePatterns: [
"/node_modules/",
"dist/",
"<rootDir>/packages/components/src/index.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed if it doesn't match the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for code coverage metrics. not sure why this file was specifically excluded before, but i kept it here to not break anything historical

@Dhaiwat10 Dhaiwat10 merged commit e3f921e into Developer-DAO:master Nov 29, 2021
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.

4 participants