-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
angular-protractor: conflict with JQuery #2734
Comments
+1 It seems that it is not possible to reference both files in the same project, even if they aren't used in the same @turp You could handle this by moving your e2e tests to a new project. |
Yeah, rather annoying even though it's not the fault of either TSD. Given that both libraries set up a global $ function, I'm not even sure you can load both underlying JS libraries at the same time? |
+1 |
I had created the above issue in typescript, but as I was thinking about it I came to the conclusion that this is likely an issue with how TSD is creating the tsd.d.ts file. Since we shouldn't be using both JQuery and angular-protractor in the same typescript file, then we should have a dedicated set of references for each scenario... However, not sure how this would be done specifically... Maybe something like having a "dev" version of a tsd.d.ts for tests? (i.e. tsd install --save-dev that would save to "tsd.dev.d.ts"?) |
I set up two TSDs, one used by my main app, and one to reference from functional test code. Obviously, the protractor d.ts isn't part of my main app TSD. |
I gave that a try & it didn't work for me. Maybe I have something different in my project, but by simply including the d.ts (regardless of the in the ts files) causes the build issue. Do you have a single VS project for both your unit\functional test code & your app? |
After playing with this for a couple hours now, it really seems like there's something off with the typescript compiler that might be compounding this issue... If I have 2 ts files in my project, 1 references angular-protractor and the other ts file references jquery, then I get "TS2134: Build: Subsequent variable declarations...". Since the ts are independent of each other and don't reference both angular-protractor & jquery at the same time, then this build issue should never be hit. I'm going to create a simple github project to demonstrate & file an issue against typescript (again). |
I don't use Visual Studio so I'm not sure if that's part of the issue or not. I use IDEA to code, and Gulp to watch the file system, compile, and produce the build artifacts. |
when Gulp compiles, does it call TSC per file or once for all files? For example,
or
Visual Studio builds the first way, which I think is why I'm seeing the issue & why having multiple tsd.d.ts files isn't working for me. I would guess Gulp does it the 2nd way (though, i've never used Gulp, so this is just a guess). |
I'm actually not sure. I have it compiling and aggregating the JS into a single file, along with a source map for easier debugging, but you can also have it compile out to individual JS files. It can also do incremental compilation for updates, which speeds things up. So it almost seems like it does both, but that's really just a guess. (If it helps, you can see what it is using here: https://github.com/ivogabe/gulp-typescript/tree/master/typescript). |
I am struggling with this issue as well |
+1 |
+1 I ended up using the workaround suggested by @awerlang. |
+1 This is most annoying. |
I'm not really sure what's not sinking in here. Angular depends on jQuery, which defines a The only possible option would be to create a Protractor TSD that omits Since I don't think there's any reason for Protractor code to depend on Angular or jQuery anyway, the only viable solution seems to be just not referencing the Angular TSD within the Protractor project/code. That probably means using a separate project, or at least separate TSD listings. |
If you're using Visual Studio to build & have both protractor/angular in the same project, then please put your "+1" in microsoft/TypeScript#1516 to let them know I'm not the only one seeing this issue |
This is the first google hit for the issue. I knew at the time it was VS's fault but the red mis, it made me do it. |
For those who want main app and tests on the same VS project, refer to PR #3528. Get it and see if anything's broken at your side. It must fix this issue. |
+1 This is really annoying indeed. I wonder why protractor used $ in the first place, wasn't jQuery well established when Protractor was developed? I can't get my e2e tests compiled with TS and TSLint and don't seem to find a way of fixing this. Has anyone found a good workaround? I was thinking about settings up two tsd folders, but since both my app and my e2e tests needs type definitions for angular this wouldn't help anyway. I understand the implications of this problem, and that it doesn't really help anyone to |
Protractor is just a wrapper for Selenium/Webdriver, which uses $ and $$ extensively. However, I'm not sure why your e2e tests project would actually need the Angular or JQuery definitions? |
+1 @brian428 Keep in mind that angular-mocks also has a reference to |
Hi guys, I sent a PR to DefinitelyTyped #4844 to allow embedding of a noConflict version of jQuery. This would be an acceptable solution for me. Please feel free to add your comments and thoughts to the proposed workaround. Until this PR is merged, I use the following
Hope this helps someone. Edit: It didn't work as expected, because version names are appended in the Best. |
Here's what I did for converting the official AngularSeed project for TypeScript : https://github.com/Microsoft/TypeScriptSamples/blob/master/angular1/CONVERSION.md The final project : https://github.com/Microsoft/TypeScriptSamples/tree/master/angular1 |
+1 |
+1 |
Remove protractor typings As detailed in this issue, DefinitelyTyped/DefinitelyTyped#2734, the protractor typings are incompatible with jQuery. The best workaround suggested is to move integration tests via protractor and selenium to a different project. Since we will likely not worry about integration tests in this project, I just removed the protractor typings.
Remove protractor typings As detailed in this issue, DefinitelyTyped/DefinitelyTyped#2734, the protractor typings are incompatible with jQuery. The best workaround suggested is to move integration tests via protractor and selenium to a different project. Since we will likely not worry about integration tests in this project, I just removed the protractor typings.
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
We should really make a new issue, this one is from 2014. |
angular1 here :) |
@jakeNiemiec Nope, using AngularJS 1.x here. We're just trying to minimize the migration effort in the future. |
+1 |
1 similar comment
+1 |
Is there any way i can use jquery and protractor typings in the same project, without modifying typings sources and without getting this error? After all this time, there must be a way :( |
+1 This is really annoying. Introduction of "Types" to Javascript is supposed to increase productivity! I am JS pro & I have been working on it since month and I still keep on getting such annoying issues which diverts your focus from actual functionality! Sadly, I don't see productivity in action with Types! |
+1 |
Fix it please! |
There is ~1000 open issues, no one is going to find this (2 years and counting). Looking at the history of contributors, @cnishina may be able to help (his profile tagline: Mission: typescript protractor tests) @vvakame is also a recent contributor (seemingly related issue here: microsoft/TypeScript#3102 (comment). |
Hi everyone. I've had this issue bookmarked for a very long time and have been meaning to respond. Since Protractor has been slowly migrating JavaScript files to TypeScript. If you are using the latest version of Protractor (v 4.0.9), it has built in TypeScript support. There is a sample TypeScript project in the Protractor repo as well as in the cookbook. Just a quick note: TypeScript support is still experimental, check the changelog for any potential breaking changes. So to not have a jQuery conflict, you must set
The import actually uses the global So let's say you are using
|
Hopefully the above response is enough to close this issue. 🎉 Below is more details about "fixing"
|
@cnishina Thanks for following up! |
@andy-ms This should be closed since angular-protractor does not exist. |
I'm seeing the following conflict when using Protractor with JQuery.
I tried to uninstall JQuery, but 'angularjs.TypeScript.DefinitelyTyped 2.0.6 depend(s) on it.
I'm using the following version:
Thanks
Jay
The text was updated successfully, but these errors were encountered: