Skip to content

chore(testing): export stubComponentCompilerMeta as mockComponentMeta#6409

Merged
johnjenkins merged 7 commits intostenciljs:mainfrom
Cliffback:export-component-compiler
Oct 3, 2025
Merged

chore(testing): export stubComponentCompilerMeta as mockComponentMeta#6409
johnjenkins merged 7 commits intostenciljs:mainfrom
Cliffback:export-component-compiler

Conversation

@Cliffback
Copy link
Copy Markdown
Contributor

@Cliffback Cliffback commented Oct 3, 2025

For being able to mock the compiler for testing custom output targets, the stubComponentCompilerMeta is very useful. Up until now, I have just copied the object, while exporting it from Stencil would be much better.

stencil-custom-suffix-output-target

So with this export, I can now just import the object like this directly:
image

Instead of manually hardcoding it like I currently do:
custom-suffix-output-target.spec-utils.ts

@Cliffback Cliffback requested a review from a team as a code owner October 3, 2025 08:44
@johnjenkins
Copy link
Copy Markdown
Contributor

@Cliffback - the pipeline is failing atm. Mind having a look? 🙏

@Cliffback
Copy link
Copy Markdown
Contributor Author

Cliffback commented Oct 3, 2025

Hmm... Stuggling to make the tests pass.

I get this currently:

image

but if i add the export to compiler/index.ts and i import stubComponentCompilerMeta from there I then get:

image

But the function is already bundled, and works fine in actual use, so seems to be just a type issue

Any suggestions, @johnjenkins?

@Cliffback Cliffback changed the title chore(testing): export stubComponentCompilerMeta chore(testing): export stubComponentCompilerMeta as mockComponent Oct 3, 2025
@johnjenkins
Copy link
Copy Markdown
Contributor

not off the top of my head. I would think however, it probably makes most sense if this object can instead be exported from the stencil/core/testing dir (e.g from ./src/testing/mocks.ts) - I know that'd take some re-working within Stencil though.

@Cliffback
Copy link
Copy Markdown
Contributor Author

not off the top of my head. I would think however, it probably makes most sense if this object can instead be exported from the stencil/core/testing dir (e.g from ./src/testing/mocks.ts) - I know that'd take some re-working within Stencil though.

Yeah. Like moving the stub-file from its current location, and into the mocks-file, and rewriting internal references to it in Stencil, or working with the bundler to keep its location but then include it in mocks.ts, or something like that?

@johnjenkins
Copy link
Copy Markdown
Contributor

Yeah. Like moving the stub-file from its current location, and into the mocks-file, and rewriting internal references to it in Stencil, or working with the bundler to keep its location but then include it in mocks.ts, or something like that?

Option 1 I think? Obvs don't know if there are any wider repercussions to that

@Cliffback
Copy link
Copy Markdown
Contributor Author

Yeah. Like moving the stub-file from its current location, and into the mocks-file, and rewriting internal references to it in Stencil, or working with the bundler to keep its location but then include it in mocks.ts, or something like that?

Option 1 I think? Obvs don't know if there are any wider repercussions to that

I'll give it a go!

For the API, does it make sense to export the stubComponentCompilerMeta as mockComponent for external use? That's at least what i use it for in my code when it comes to it.

@Cliffback
Copy link
Copy Markdown
Contributor Author

@johnjenkins I think it actually was as simple as not just reexporting, but explicitly importing and exporting on different lines. I at least managed to pass the failing command locally. Perhaps restart the workflow to see if it passes now?

@johnjenkins
Copy link
Copy Markdown
Contributor

For the API, does it make sense to export the stubComponentCompilerMeta as mockComponent for external use? That's at least what i use it for in my code when it comes to it.

I think mockComponentMeta is a bit more descriptive?

@johnjenkins
Copy link
Copy Markdown
Contributor

johnjenkins commented Oct 3, 2025

@johnjenkins I think it actually was as simple as not just reexporting, but explicitly importing and exporting on different lines. I at least managed to pass the failing command locally. Perhaps restart the workflow to see if it passes now?

Aside from formatting / linting it looks happier!

@Cliffback
Copy link
Copy Markdown
Contributor Author

Cliffback commented Oct 3, 2025

mockComponentMeta

Aggreed

Aside from formatting / linting it looks happier!

Awesome. Will fix linting and rename to mockCompilerMeta

@Cliffback Cliffback changed the title chore(testing): export stubComponentCompilerMeta as mockComponent chore(testing): export stubComponentCompilerMeta as mockComponentMeta Oct 3, 2025
@Cliffback
Copy link
Copy Markdown
Contributor Author

@johnjenkins Should be good now. Is PR title okay?

@johnjenkins
Copy link
Copy Markdown
Contributor

@johnjenkins Should be good now. Is PR title okay?

image

:D - npm run prettier && npm run lint --fix

@Cliffback
Copy link
Copy Markdown
Contributor Author

Sorry, forgot to run prettier as well, should be updated now.

@johnjenkins johnjenkins added this pull request to the merge queue Oct 3, 2025
@johnjenkins johnjenkins removed this pull request from the merge queue due to a manual request Oct 3, 2025
@johnjenkins johnjenkins merged commit ef05b45 into stenciljs:main Oct 3, 2025
69 checks passed
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.

2 participants