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

fix(tests): add global scripts in karma plugin #3543

Merged
merged 2 commits into from
Dec 22, 2016

Conversation

filipesilva
Copy link
Contributor

Note: renamed and lazy global scripts are not supported.

Fix #2897

@filipesilva
Copy link
Contributor Author

@YonatanKra can you also review this approach, and confirm it works for your scenario?

I opted to add these changes in the karma plugin to ensure that karma can be ran separately from the ng test command.

@Meligy
Copy link
Contributor

Meligy commented Dec 13, 2016

A similar approach would work for serving assets too, right?

// Unshift elements onto the beginning of the files array.
// It's important to not replace the array, because
// karma already has a reference to the existing array.
Array.prototype.unshift.apply(config.files, globalScriptPatterns);
Copy link
Contributor

Choose a reason for hiding this comment

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

config.files.unshift(...globalScriptsPatterns) is simpler.

Copy link
Contributor Author

@filipesilva filipesilva Dec 20, 2016

Choose a reason for hiding this comment

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

We can't do that in the karma plugin since it's not preprocessed and node4 does not support the spread operator (without a flag).

I hope to tackle that in #3605 by making the plugin be in TypeScript.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

Note: renamed and lazy global scripts are not supported.

Fix angular#2897
@filipesilva
Copy link
Contributor Author

@Meligy I had to remove your test setup code because I couldn't have tests afterwards without manually cleaning up the previous ones:

return Promise.resolve()		
    .then(() => testWatchFalseAndSingleRun())		
    .then(() => testAssetsAreServed());

Our test scripts already reset code to it's initial state after each test so it's better to have one file for each test.

@Meligy
Copy link
Contributor

Meligy commented Dec 22, 2016

That's perfect. I didn't want to change / introduce file convention in previous commit, but the current way in this PR is super awesome.

@hansl
Copy link
Contributor

hansl commented Dec 22, 2016

LGTM. Cheers!

@filipesilva filipesilva merged commit 1153c92 into angular:master Dec 22, 2016
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
Note: renamed and lazy global scripts are not supported.

Fix angular#2897
@filipesilva filipesilva deleted the fix-scripts-karma-plugin branch February 25, 2017 11:27
@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.

[Bug] Global libraries won't be auto loaded when running ng test
4 participants