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

feat(ct): class and object components #30269

Closed
wants to merge 1 commit into from

Conversation

sand4rt
Copy link
Collaborator

@sand4rt sand4rt commented Apr 5, 2024

closes #29544, #29928, partially #31217 and introduces an improved approach for creating multiple wrapper/story components within a single file (considering it's only possible to define one component in a .vue file). @yjaaidi made the change in tsxTransform.ts

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Apr 5, 2024

Test results for "tests 1"

2 flaky ⚠️ [chromium-library] › library/capabilities.spec.ts:140:3 › should not crash on showDirectoryPicker
⚠️ [chromium-library] › library/tracing.spec.ts:243:5 › should not include trace resources from the previous chunks

26930 passed, 619 skipped
✔️✔️✔️

Merge workflow run.

@sand4rt
Copy link
Collaborator Author

sand4rt commented Apr 25, 2024

@pavelfeldman any chance this one could passthrough?

@sand4rt sand4rt mentioned this pull request May 7, 2024
10 tasks
@pavelfeldman
Copy link
Member

👋 @sand4rt 👋 taking care of our review debt. is this something you'd like me to look at?

@sand4rt
Copy link
Collaborator Author

sand4rt commented May 24, 2024

👋 @pavelfeldman, yes please. Let me know if more info is needed.

I think @dgozman also has an opinion about this BTW. He mentioned something about this during the Angular PR review (a similar change is proposed there): #27783 (comment)

@@ -2,6 +2,7 @@ import { test, expect } from '@playwright/experimental-ct-vue';
import Button from '@/components/Button.vue';
import EmptyTemplate from '@/components/EmptyTemplate.vue';
import Component from '@/components/Component.vue';
import { Story } from '@/components/Story';
Copy link
Member

Choose a reason for hiding this comment

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

How typical is this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It depends on the app, but I don't it's that typical; its useful when a wrapper/story needs to be created to test components, where Playwright cannot serialise the data sent to the browser (such as unserialisable props). It's possible to create multiple .vue files but that's quite cumbersome.

There are additional use cases where importing components from a .ts file would be beneficial tho, such as supporting Angular and web components (without relying on a specific file extension).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This use case is very typical for Vue and is not possible without this PR: #31217

traverse(node, {
enter: p => {
// Treat calls to mount and all identifiers in arguments as component usages e.g. mount(Component)
if (t.isCallExpression(p.node) && t.isIdentifier(p.node.callee) && p.node.callee.name === 'mount') {
Copy link
Member

Choose a reason for hiding this comment

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

We used to have this as you probably know. But the isIdentifier(p.node.callee) felt overly restrictive and limited us a couple of times.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see how? What approach would you recommend to address this? In my opinion, relying solely on file extension is not a viable option.

@pavelfeldman
Copy link
Member

We are slow on it, let me close it as we are figuring out what we do with CT. The code is not the problem, so there is no good reason for this PR to be here held back by the reviews.

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.

[Bug]: Angular/Web component tests fail with .ts or .js as file extension
2 participants