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

Add an extraCliArgs option to the emberNew helper #394

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Windvis
Copy link
Contributor

@Windvis Windvis commented Dec 10, 2024

This makes it possible to pass any extra arguments to ember-cli.

Closes #391 and unblocks emberjs/ember.js#20771

return emberNew({ extraCliArgs: ['--typescript', '--no-welcome']})
.then(() => {
const appPath = path.resolve(process.cwd(), 'app');
expect(fs.existsSync(appPath)).to.equal(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't really test the extra option, but I'm not sure how to test it either.

Testing the output of an actual existing cli options seems frail.

Should I try to use some sort of mocking / stubbing of the ember function to see if it's called with the extra arguments we pass?

I found https://github.com/theKashey/rewiremock, which might be useful for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried using testdouble.js since we already depend on that, but I can't get it to work.. I just want to spy on the ember function that's used inside emberNew but it doesn't work as expected. I assume I'm doing something wrong here but I'm not sure if I want to keep spending time on this either..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got something to work but it's not the prettiest. testdouble doesn't make it easy to do what I want (by design) but I think it's the best option we have without installing new dependencies.

This makes it possible to pass any extra arguments to ember-cli, which makes it possible to test more blueprint scenarios.
@Windvis Windvis force-pushed the emberNew-extra-arguments branch from 7aad077 to f4ff8d5 Compare December 10, 2024 11:20
return emberNew({ extraCliArgs: ['--typescript', '--no-welcome'] })
.then(() => {
// If we get here that means our testdouble matcher worked and things were called as expected.
expect(true).to.be.true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

testdouble has a td.verify feature, but using that here will also run the thenDo callback again, which causes issues. There doesn't seem to be a way to simply check the times it was called and with which arguments.

I'm not sure we need the expect either, maybe it's good enough if the test doesn't throw an error?

This uses testdouble.js to spy on the `ember` call that is done by `emberNew`.
@Windvis Windvis force-pushed the emberNew-extra-arguments branch from 756c051 to dccf643 Compare December 10, 2024 15:22
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.

Support adding extra arguments to the ember new/addon commands.
1 participant