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

Serve assets files from ng test #3628

Merged
merged 2 commits into from
Dec 20, 2016
Merged

Conversation

Meligy
Copy link
Contributor

@Meligy Meligy commented Dec 19, 2016

Closes #2803.

This pull request makes the files in the assets property of angular-cli.json get served from the web server running ng test tests.

It's very heavily inspired by @filipesilva's similar pull request #3543 that adds similar support for the scripts property (Thanks heaps Mr Filipe!).

@Meligy Meligy force-pushed the feature/karma-assets branch 4 times, most recently from f8148bf to 082e260 Compare December 19, 2016 21:53
@hansl
Copy link
Contributor

hansl commented Dec 20, 2016

@filipesilva could you review? This LGTM but I want your eyes on it since you did the same for scripts.

@hansl hansl requested a review from filipesilva December 20, 2016 01:31
@Meligy Meligy force-pushed the feature/karma-assets branch from 082e260 to 9ba5000 Compare December 20, 2016 03:30
Copy link
Contributor

@filipesilva filipesilva left a comment

Choose a reason for hiding this comment

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

Logic, implementation and test seem solid. I left a question but it's mostly curiosity.

Thanks for making this happen @Meligy, cheers!

served: true,
watched: true
});
config.proxies['/' + proxyPath] = '/base/' + appConfig.root + '/' + proxyPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are proxies always needed?

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'm no karma expert and worked my way through trial and error really, but according to the docs and my tries, when you add a file to the files array, it gets served from /base/src/path-to-file only. The proxy adds another endpoint (like a URL rewrite) from /path-to-file to /base/src/path-to-file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@filipesilva I added a comment explaining why we need proxies.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that makes sense to me. I remember a similar situation I ran into another project. Without the proxy, fetch would not work correctly.

@Meligy Meligy force-pushed the feature/karma-assets branch from 9ba5000 to 6d302e4 Compare December 20, 2016 11:38
@hansl hansl merged commit 3459300 into angular:master Dec 20, 2016
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ng test gives 404 from assets files
4 participants