Hi i am trying to run a simple protractor test(new to protracotor) but i keep getting this error.Below is my package.json
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.8",
"@angular/cli": "~8.3.8",
"@angular/compiler-cli": "~8.2.9",
"@angular/language-service": "~8.2.9",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "12.12.7",
"codelyzer": "^5.0.0",
"husky": "^3.0.9",
"jasmine-core": "~3.4.0",
"jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-junit-reporter": "^2.0.1",
"protractor": "~5.4.0",
"puppeteer": "^2.0.0",
"ts-node": "~7.0.0",
"tslint": "^5.15.0",
"typescript": "~3.6.4"
}
In my case, the issue was due to a wrong import in a component.
I wrongly wrote this
import { EventEmitter } from 'protractor';
Instead of writing below import:
import { EventEmitter } from '@angular/core';
Seems like the issue with compatibility: https://github.com/angular/protractor/issues/5348
I have fixed it by downgrading typescript to 3.6.2 from 3.7.X
If you don't want to downgrade, you can fix the import this way (protractor 5.4.2):
import { ElementHelper, ProtractorBrowser } from './browser';
import { ElementArrayFinder, ElementFinder } from './element';
import { ProtractorExpectedConditions } from './expectedConditions';
import { ProtractorBy } from './locators';
import { Ptor } from './ptor';
export { ActionSequence, Browser, Builder, Button, Capabilities, Capability, error, EventEmitter, FileDetector, Key, logging, promise, Session, until, WebDriver, WebElement, WebElementPromise } from 'selenium-webdriver';
export { ElementHelper, ProtractorBrowser } from './browser';
export { Config } from './config';
export { ElementArrayFinder, ElementFinder } from './element';
export { ProtractorExpectedConditions } from './expectedConditions';
export { Locator, ProtractorBy } from './locators';
export { PluginConfig, ProtractorPlugin } from './plugins';
export { Ptor } from './ptor';
export { Runner } from './runner';
export declare let utils: {
firefox: any;
http: any;
remote: any;
};
export declare let Command: any;
export declare let CommandName: any;
export declare let protractor: Ptor;
export declare let browser: ProtractorBrowser;
export declare let $: (search: string) => ElementFinder;
export declare let $$: (search: string) => ElementArrayFinder;
export declare let element: ElementHelper;
export declare let By: ProtractorBy;
export declare let by: ProtractorBy;
export declare let ExpectedConditions: ProtractorExpectedConditions;
Basically, there is a dupe import which we need to get rid of. Attached you have the patch:
diff -r d5e827235972 yf/src/myapp/node_modules/protractor/built/index.d.ts
--- a/yf/src/myapp/node_modules/protractor/built/index.d.ts Sun Jan 19 20:49:39 2020 +0100
+++ b/yf/src/myapp/node_modules/protractor/built/index.d.ts Sun Jan 19 21:13:41 2020 +0100
@@ -2,7 +2,6 @@
import { ElementArrayFinder, ElementFinder } from './element';
import { ProtractorExpectedConditions } from './expectedConditions';
import { ProtractorBy } from './locators';
-import { PluginConfig, ProtractorPlugin } from './plugins';
import { Ptor } from './ptor';
export { ActionSequence, Browser, Builder, Button, Capabilities, Capability, error, EventEmitter, FileDetector, Key, logging, promise, Session, until, WebDriver, WebElement, WebElementPromise } from 'selenium-webdriver';
export { ElementHelper, ProtractorBrowser } from './browser';
@@ -10,10 +9,9 @@
export { ElementArrayFinder, ElementFinder } from './element';
export { ProtractorExpectedConditions } from './expectedConditions';
export { Locator, ProtractorBy } from './locators';
+export { PluginConfig, ProtractorPlugin } from './plugins';
export { Ptor } from './ptor';
export { Runner } from './runner';
-export declare type PluginConfig = PluginConfig;
-export declare type ProtractorPlugin = ProtractorPlugin;
export declare let utils: {
firefox: any;
http: any;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With