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

Start testing component compilation #154

Closed
wants to merge 5 commits into from

Conversation

NullVoxPopuli
Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli commented Jul 15, 2023

Builds on top of: #151

tests that various component scenarios are generated correctly

(basically snapshot testing with files)

This will allow us to feel more comfortable with switching up the rollup config without worrying about breaking stuff in the future.

In an effort to keep PRs small, and avoid overwhelming reviewers, I've kept the number of tests added to a small amount, and will add more in follow up PRs.

In particular, we need:

  • template-only components
  • private / non-re-exported components
  • non-entrypoint files in general
  • keepAssets behavior
  • gjs / gts, even though we don't generate support for this by default
  • and more!

@NullVoxPopuli NullVoxPopuli force-pushed the test-component-outputs branch 2 times, most recently from 176e1a7 to fc2a517 Compare July 15, 2023 16:17
@NullVoxPopuli NullVoxPopuli force-pushed the test-component-outputs branch 2 times, most recently from 72237eb to 5aeec9b Compare July 15, 2023 19:04
@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review July 15, 2023 19:05
@NullVoxPopuli NullVoxPopuli changed the title Start stubbing out build tests Start testing component compilation Jul 15, 2023
@NullVoxPopuli NullVoxPopuli force-pushed the test-component-outputs branch from 0c1ffd0 to e20f37a Compare July 15, 2023 20:12
Comment on lines +22 to +27
let { name } = await createAddon({
args: [`--pnpm=true`, '--addon-only'],
options: { cwd: tmpDir },
});

cwd = path.join(tmpDir, name);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit, and unrelated to this PR really, but as I'm seeing this code here... createAddon receives tmpDir, and returns name, so has everything to compute cwd, so could we do this to simplify this a bit?

Suggested change
let { name } = await createAddon({
args: [`--pnpm=true`, '--addon-only'],
options: { cwd: tmpDir },
});
cwd = path.join(tmpDir, name);
let { name, addonDir: cwd } = await createAddon({
args: [`--pnpm=true`, '--addon-only'],
options: { cwd: tmpDir },
});

import { matchesFixture } from './assertions.js';
import { copyFixture, runScript } from './utils.js';

export class AddonFixtureHelper {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't want to overcomplicate things, but with #151 providing some testing infrastructure, should't this file and copyFixture ideally been part of that PR rather? 😅

Another though here, and I am totally fine ignoring this for now, like doing later or not doing at all, but given we have a more elaborate testing class here (i.e. it own some state), does it make sense to integrate createAddon into this? Like rename to e.g. TestAddonBuilder and do the addon creation as part of the constructor? Just thinking aloud here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should't this file and copyFixture ideally been part of that PR rather?

yes! I will move it over there -- I have a fear of making PRs too big -- especially when utils-prs really need usages to see how the utils will be used / what their purpose is.

does it make sense to integrate createAddon into this? Like rename to e.g. TestAddonBuilder and do the addon creation as part of the constructor?

I really like this idea 🎉 will do

it('generates correct files with no template', async () => {
await addonOnlyJS.use('src/components/no-template.js');
await addonOnlyJS.build();
await addonOnlyJS.matches('dist/components/no-template.js');
Copy link
Collaborator

@simonihmig simonihmig Jul 16, 2023

Choose a reason for hiding this comment

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

Tbh I am not sure if I would want these kind of snapshot tests against dist-output. Wouldn't these test become super brittle? Like you could update something rollup or babel dependency, which makes the out put slightly different but still perfectly valid, but still you would have tests failing. Especially annoying if you have to fix renovate PRs by hand all the time...

I do see value for fixture-based tests for all the blueprint-generated files, especially those whose content cannot be covered by smoke tests, like e.g. correct path, package manager calls etc. in the generated CONTRIBUTING.md.

But for the dist-output we don't have to care what the content really is, we only need to care if it works as expected. And we could cover this by making our smoke tests more detailed, like having different forms of components (TO, colocated, <template> and whatnot), and having a test (by means of a fixture?) in the generated addon that would cover this when running the smoke test, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, these are good points -- my thinking with these tests is that they'd be faster than full smoke tests.

But maybe it's still worth it?
Because ultimately we do still want to make sure that each compiled component can be rendered.

I will adjust to more e2e-style

console.debug(`Debug test repo at ${tmpDir}`);

let { name } = await createAddon({
args: [`--pnpm=true`, '--addon-only'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we doing this for addon-only here? When setting up new tests, shouldn't we just start with the default scenario first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

related to here i was focusing on compiled output, rather than e2e "workingness", if that makes sense -- I'm going to shift to the default scenario tho, and make sure that each type of component can be rendered in the test-app

@NullVoxPopuli NullVoxPopuli force-pushed the add-fixture-utils branch 3 times, most recently from 387847b to 5d2aae9 Compare July 17, 2023 12:27
Base automatically changed from add-fixture-utils to main July 17, 2023 12:31
@NullVoxPopuli
Copy link
Collaborator Author

Going to close this while I address PR feedback in a separate PR, vie existing smoke tests

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