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

refactor: Graph analysis - unit testing #6727

Merged
merged 6 commits into from
Sep 13, 2022

Conversation

elliott-with-the-longest-name-on-github
Copy link
Contributor

The first of what I hope will be a long line of PRs leading up to 1.0 that focus on refactoring code to add unit tests and remove integration tests. Our test suites are starting to drag on to infinity, making merging PRs quickly a bit of a chore. Unfortunately, in this case, we haven't been able to remove any integration tests, but I think the unit tests do a much better job of covering all cases in a clean and readable way (that doesn't abuse TypeScript like we used to!).

We can't remove the integration tests because there's not really a great way to unit test our dependency on Vite and Rollup's module graph implementations. Sure, we could do some dumb and labor-intensive mock of their implementations, but that wouldn't really give us any benefits. We should continue to rely on the integration tests to see how this feature interacts with the real Rollup/Vite environment during dev and build.

Just a note: The graph analysis stuff is pretty self-contained and doesn't really feel at home in a utils.js file, so I moved it to its own folder to separate it and its types from the rest of the project.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Sep 10, 2022

🦋 Changeset detected

Latest commit: 6a7e304

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
'@sveltejs/kit': patch
---

[chore] Refactor graph analysis for better unit tests
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this warrants a changeset. There are (or at least there should be) no user-visible changes.

Choose a reason for hiding this comment

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

I don't have a strong opinion here. There's a pretty contentious issue on the semver GitHub debating whether refractors are patches. I tend to fall on the "Don't release a refactor by itself, but include it in the patch notes because you did change the code" camp.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, it's an issue we've debated in the past. My personal opinion is basically the same as @tcc-sejohnson's because if the reactor breaks something it's way easier to track down the issue when the change is in the changelog. And I think prefixing it with [chore] as done here means people can easily ignore it when reading the changelog

@Rich-Harris Rich-Harris merged commit 3b457f6 into master Sep 13, 2022
@Rich-Harris Rich-Harris deleted the sejohnson-refactor-and-test-graphs branch September 13, 2022 14:03
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