-
Notifications
You must be signed in to change notification settings - Fork 12k
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
fix(new): include routing in spec and inline template when called with --routing
#3252
Conversation
d0e7918
to
da5823e
Compare
--routing
flag--routing
da5823e
to
4c7f8eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one nit to add.
TestBed.configureTestingModule({<% if (routing) { %> | ||
imports: [ | ||
RouterTestingModule | ||
],<% } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're fixing this, can you add a compileComponents
call in here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Oh and before I forget, seems like we missed this because we're missing an e2e test. Could you add one? |
4c7f8eb
to
6854bb5
Compare
@hansl I attempted to add an e2e test for |
2bea7bc
to
06f85cb
Compare
I made the test specific for |
06f85cb
to
2131fbf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more comments.
@@ -57,6 +57,27 @@ export function createDir(path: string) { | |||
_recursiveMkDir(path); | |||
} | |||
|
|||
export function deleteDir(path: string) { | |||
return Promise.resolve() | |||
.then(() => _recursiveRmDir(path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use rimraf
here (it's already in the dependencies, documentation here: https://github.com/isaacs/rimraf).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we don't need it to make this e2e test, so let's just kill it :)
TestBed.configureTestingModule({<% if (routing) { %> | ||
imports: [ | ||
RouterTestingModule | ||
],<% } %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
const parentTestProjectDir = process.cwd(); | ||
const ngNewProjectName = 'new-test-project'; | ||
|
||
return Promise.resolve() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to overly complicate how this test could work. Why not:
return return Promise.resolve()
.then(() => process.chdir(getGlobalVariable('tmp-root')))
.then(() => ng('new', 'routing-project', '--routing'))
.then(() => process.chdir(path.join('routing-project')))
.then(() => ng('test', '--single-run'));
The only thing missing would be to chdir
back to the directory we were in before this test, but really e2e_runner
should take care of that (and I'm going to do a PR for it).
We already work off a temporary directory, there's no need to clean up after yourself :) This is by design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3287 will fix the chdir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You keep showing me awesome gems. I didn't realise the getGlobalVariable()
before!
Will update tomorrow or today if I have time.
2131fbf
to
8189d8f
Compare
27a3651
to
d9afc7e
Compare
d9afc7e
to
f09f06c
Compare
Aaand we finally got a green build! @hansl do you think this PR can be merged now? Anything else you'd think is needed? |
LGTM! Thanks! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #3331
This is kind-of missed work from #2794.
In that other PR, we prevented a browser error that happens when a user just runs:
This works great now after #2794 was cherry picked.
However, there were 2 missing items:
ng test
failsBecause the
app.component
has<router-outlet>
, but the test does not import a routing module--inline-template
withng new --routing
Because we only fixed
app.component.html
, but not the actualtemplate
inapp.component.ts
This PR addresses these 2 issues.
Tests
I am really keen to add some tests to this PR.Acceptance tests are not applicable here because they only check created files not file content, and I could not find any E2E tests for
ng new
that I could use for inspiration, or I could extend to cover this scenario.Update: Thanks Hans for guidance. Tests were added.