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
hansl
left a comment
There was a problem hiding this comment.
LGTM, just one nit to add.
| TestBed.configureTestingModule({<% if (routing) { %> | ||
| imports: [ | ||
| RouterTestingModule | ||
| ],<% } %> |
There was a problem hiding this comment.
While we're fixing this, can you add a compileComponents call in here as well?
|
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
tests/e2e/utils/fs.ts
Outdated
|
|
||
| export function deleteDir(path: string) { | ||
| return Promise.resolve() | ||
| .then(() => _recursiveRmDir(path)); |
There was a problem hiding this comment.
Use rimraf here (it's already in the dependencies, documentation here: https://github.com/isaacs/rimraf).
There was a problem hiding this comment.
Actually we don't need it to make this e2e test, so let's just kill it :)
| TestBed.configureTestingModule({<% if (routing) { %> | ||
| imports: [ | ||
| RouterTestingModule | ||
| ],<% } %> |
| const parentTestProjectDir = process.cwd(); | ||
| const ngNewProjectName = 'new-test-project'; | ||
|
|
||
| return Promise.resolve() |
There was a problem hiding this comment.
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.
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 testfailsBecause the
app.componenthas<router-outlet>, but the test does not import a routing module--inline-templatewithng new --routingBecause we only fixed
app.component.html, but not the actualtemplateinapp.component.tsThis 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 newthat I could use for inspiration, or I could extend to cover this scenario.Update: Thanks Hans for guidance. Tests were added.