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

test: refactor ng-add to make it easier to add moar tests #974

Conversation

davidlj95
Copy link
Owner

Issue or need

After starting to add more features to the ng-add schematic, noticed that same test code repeats over and over.

Despite being conscious that WET > DRY in tests, the Twice of WET was definitely not twice.

Some things can be abstracted to avoid repeating the same tests around and around.

Proposed changes

Add an abstraction to allow testing whether providers are added or not to the root file (app config / app module): shouldAddRootProvider.

Also extracts util functions into testing directories

Quick reminders

  • 🤝 I will follow Code of Conduct
  • No existing pull request already does almost same changes
  • 👁️ Contributing docs are something I've taken a look at
  • 📝 Commit messages convention has been followed
  • 💬 TSDoc comments have been added or updated indicating API visibility if API surface has changed.
  • 🧪 Tests have been added if needed. For instance, if adding new features or fixing a bug. Or removed if removing features.
  • ⚙️ API Report has been updated if API surface is altered.

Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @davidlj95 and the rest of your teammates on Graphite Graphite

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0639ca0) to head (bdcf51d).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #974   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           86        86           
  Lines          365       365           
  Branches        52        52           
=========================================
  Hits           365       365           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Oct 21, 2024

📦 Bundle size (Angular v15)

Git ref: bdcf51d5707bd02dc5b03f2fe8ba7560df221be7

Module file Size Base size Difference
ngx-meta-core.mjs 3665 bytes (3.6KiB) 3665 bytes (3.6KiB) No change
ngx-meta-json-ld.mjs 352 bytes (352B) 352 bytes (352B) No change
ngx-meta-open-graph.mjs 1172 bytes (1.2KiB) 1172 bytes (1.2KiB) No change
ngx-meta-routing.mjs 557 bytes (557B) 557 bytes (557B) No change
ngx-meta-standard.mjs 959 bytes (959B) 959 bytes (959B) No change
ngx-meta-twitter-card.mjs 599 bytes (599B) 599 bytes (599B) No change
Total 7304 bytes (7.2KiB) 7304 bytes (7.2KiB) No change

Copy link

github-actions bot commented Oct 21, 2024

📦 Bundle size (Angular v16)

Git ref: bdcf51d5707bd02dc5b03f2fe8ba7560df221be7

Module file Size Base size Difference
ngx-meta-core.mjs 3705 bytes (3.7KiB) 3705 bytes (3.7KiB) No change
ngx-meta-json-ld.mjs 367 bytes (367B) 367 bytes (367B) No change
ngx-meta-open-graph.mjs 1202 bytes (1.2KiB) 1202 bytes (1.2KiB) No change
ngx-meta-routing.mjs 572 bytes (572B) 572 bytes (572B) No change
ngx-meta-standard.mjs 974 bytes (974B) 974 bytes (974B) No change
ngx-meta-twitter-card.mjs 614 bytes (614B) 614 bytes (614B) No change
Total 7434 bytes (7.3KiB) 7434 bytes (7.3KiB) No change

Copy link

github-actions bot commented Oct 21, 2024

📦 Bundle size (Angular v17)

Git ref: bdcf51d5707bd02dc5b03f2fe8ba7560df221be7

Module file Size Base size Difference
ngx-meta-core.mjs 3205 bytes (3.2KiB) 3205 bytes (3.2KiB) No change
ngx-meta-json-ld.mjs 217 bytes (217B) 217 bytes (217B) No change
ngx-meta-open-graph.mjs 931 bytes (931B) 931 bytes (931B) No change
ngx-meta-routing.mjs 394 bytes (394B) 394 bytes (394B) No change
ngx-meta-standard.mjs 857 bytes (857B) 857 bytes (857B) No change
ngx-meta-twitter-card.mjs 487 bytes (487B) 487 bytes (487B) No change
Total 6091 bytes (6.0KiB) 6091 bytes (6.0KiB) No change

Copy link

github-actions bot commented Oct 21, 2024

📦 Bundle size (Angular v18)

Git ref: bdcf51d5707bd02dc5b03f2fe8ba7560df221be7

Module file Size Base size Difference
ngx-meta-core.mjs 3205 bytes (3.2KiB) 3205 bytes (3.2KiB) No change
ngx-meta-json-ld.mjs 217 bytes (217B) 217 bytes (217B) No change
ngx-meta-open-graph.mjs 931 bytes (931B) 931 bytes (931B) No change
ngx-meta-routing.mjs 394 bytes (394B) 394 bytes (394B) No change
ngx-meta-standard.mjs 857 bytes (857B) 857 bytes (857B) No change
ngx-meta-twitter-card.mjs 487 bytes (487B) 487 bytes (487B) No change
Total 6091 bytes (6.0KiB) 6091 bytes (6.0KiB) No change

@davidlj95 davidlj95 force-pushed the stacked/test-refactor-ng-add-to-make-it-easier-to-add-moar-tests branch from 22dd9c2 to bdcf51d Compare October 21, 2024 15:04
@davidlj95 davidlj95 marked this pull request as ready for review October 21, 2024 15:06
@davidlj95 davidlj95 enabled auto-merge (squash) October 21, 2024 15:06
@davidlj95 davidlj95 disabled auto-merge October 21, 2024 15:28
@davidlj95 davidlj95 merged commit b028e11 into main Oct 21, 2024
33 checks passed
@davidlj95 davidlj95 deleted the stacked/test-refactor-ng-add-to-make-it-easier-to-add-moar-tests branch October 21, 2024 15:28
Copy link

🎉 This PR is included in version 1.0.0-beta.27 🎉

The release is available on:

Your semantic-release bot 📦🚀

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 this pull request may close these issues.

1 participant