Does anyone having problems with running e2e tests using Protractor in Angular 13?

Viewed 332

We are using protractor for our e2e tests and this was working fine till we've upgraded to Angular 13. If we run the tests now we get the following error:

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.

I've already tried several things like adding "type" : "module" to the package.json file or changing the module from commonjs to es2020 in the tsconfig.json file. All without success.

Does anyone experience the same and maybe have a solution?

1 Answers

In my case, I had different "module" values in tsconfig.json files.

For the app (after ng13 upgrade): "module": "es2020" For e2e: "module": "commonjs"

Also, I had a lot of places in e2e where I used types, defined in the app itself. Once I removed all the app types references from e2e, the error is gone.

Related