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

chore: auto-generate Lit test files #8561

Merged
merged 9 commits into from
Jan 29, 2025
Merged

chore: auto-generate Lit test files #8561

merged 9 commits into from
Jan 29, 2025

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Jan 24, 2025

Description

The PR introduces automatic generation of Lit test files using symlinks:

  1. generateLitTests script creates [name]-lit.generated.test.js symlinks for [name].test.js test files for components that have a Lit version. This effectively causes web-test-runner to run the same file twice while displaying them as separate files in the list of test files, which preserves the ability to open and debug these files separately.
  2. Then, web-test-runner plugin automatically rewrites component imports to their Lit versions when executing [name]-lit.generated.test.js.
  3. This approach doesn't affect existing -lit.test.js and -polymer.test.js, which makes it possible to transition back to a single test file approach gradually.

Type of change

  • Internal

@vursen vursen changed the title test: auto-generate Lit test files chore: auto-generate Lit test files Jan 24, 2025
@vursen vursen force-pushed the auto-generate-lit-tests branch from f29a54c to 7294d27 Compare January 25, 2025 14:26
Copy link
Contributor

@sissbruecker sissbruecker left a comment

Choose a reason for hiding this comment

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

I like the idea, seems to work well locally. Looks like CI actions didn't run with the latest changes, so would require checking if there is an actual issue there.

return !/(-polymer|-lit)(\.generated)?\.test/u.test(testPath);
})
.forEach((testPath) => {
console.log(testPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be moved into the if condition below so this only gets logged if the symlink doesn't exist yet. Otherwise it creates noise on every test run.

Copy link
Contributor Author

@vursen vursen Jan 28, 2025

Choose a reason for hiding this comment

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

Thanks, it's actually a leftover from the development. I'll remove it completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@vursen vursen removed the request for review from tomivirkki January 29, 2025 10:25
@vursen vursen merged commit 91d99d2 into main Jan 29, 2025
9 checks passed
@vursen vursen deleted the auto-generate-lit-tests branch January 29, 2025 12:57
@vaadin-bot
Copy link
Collaborator

Hi @vursen and @vursen, when i performed cherry-pick to this commit to 24.5, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 91d99d2
error: could not apply 91d99d2... test: generate Lit test files automatically (#8561)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

vursen added a commit that referenced this pull request Jan 29, 2025
vursen added a commit that referenced this pull request Jan 31, 2025
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.7.0.alpha7 and is also targeting the upcoming stable 24.7.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants