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

Is protractor no longer working when using Angular 13? #5544

Open
Heines1983 opened this issue Jan 14, 2022 · 8 comments
Open

Is protractor no longer working when using Angular 13? #5544

Heines1983 opened this issue Jan 14, 2022 · 8 comments

Comments

@Heines1983
Copy link

I'm using protractor and recently upgraded from Angular 12 to Angular 13. I now get an error while starting the e2e tests.

Error: Error [ERR_REQUIRE_ESM]: require() of ES Module C:\git\ClientApp\node_modules@angular\cdk\fesm2015\testing.mjs not supported. Instead change the require of C:\git\ClientApp\node_modules@angular\cdk\fesm2015\testing.mjs to a dynamic import() which is available in all CommonJS modules.

Is this something caused by protractor, angular/cdk or something else?

@StanislavKharchenko
Copy link

I think this question should be addressed in angular/angular project.

@andredesousa
Copy link

Hi @Heines1983,
I think this must be a problem with your e2e/tsconfig.json file.
Please check the module attribute in your configuration.

Here's an example:

{ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/e2e", "module": "commonjs", "types": [ "jasmine", "node" ] } }

Or you can see the file in my project with Angular 13 and Protractor :
https://github.com/andredesousa/angular-linters/blob/main/e2e/tsconfig.json

@rbirkgit
Copy link

The issue is that you are trying to use an ES Module lib but you are running protractor with CommonJS which does not support it. I had the same problem updating to ang13. Our libs no longer generate UMD modules and we can no longer run protractor with them. Need to build our libs with a different tool than ng-packagr that still support UMD.

@andredesousa
Copy link

@rbirkgit Yes, cannot import Angular libs for Protractor tests after Angular 13.

@robertIsaac
Copy link

The issue is that you are trying to use an ES Module lib but you are running protractor with CommonJS which does not support it. I had the same problem updating to ang13. Our libs no longer generate UMD modules and we can no longer run protractor with them. Need to build our libs with a different tool than ng-packagr that still support UMD.

@rbirkgit did you manage to find a fix?

@rbirkgit
Copy link

I changed to build our lib with rollup which supports CommonJS/UMD

@symeonmattes
Copy link

I changed to build our lib with rollup which supports CommonJS/UMD

Could you give some references? I have the same issue and I haven't found a solution yet.

@symeonmattes
Copy link

symeonmattes commented Dec 14, 2023

Just in case somebody else has the same issue. Protractor and cucumber worked quite fine for me, but I haven't realized that in one of my steps, I was using angular libraries which indeed have a problem with protractor, as libraries in angular are esm, while in protractor commonjs. I had to replace some functions with pure typescript, js libraries, e.g. HTTP client for API calls, with request from nodejs, or axios library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants