nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.62k stars 2.36k forks source link

Can't run Protractor e2e on newly generate Angular app #4035

Closed devinshoemaker closed 3 years ago

devinshoemaker commented 4 years ago

Current Behavior

Protractor e2e tests fail on a newly generated Nrwl Angular application with the error:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
: Compiled successfully.
[08:01:26] I/launcher - Running 1 instances of WebDriver
[08:01:26] I/direct - Using ChromeDriver directly...
[08:01:27] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript:
error TS5083: Cannot read file '/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/tsconfig.json'.

    at createTSError (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/ts-node/src/index.ts:261:12)
    at Object.register (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/ts-node/src/index.ts:265:42)
    at onPrepare (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/apps/my-app-e2e/protractor.conf.js:25:24)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:46:49
    at Function.promise (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:682:9)
    at Object.runFilenameOrFn_ (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:38:16)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/runner.js:98:27
    at _fulfilled (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:834:54)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:796:13)

It appears that the e2e tsconfig is extending the wrong file. It should be "extends": "../../tsconfig.base.json". However, after changing this, I receive a different error:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
: Compiled successfully.
[08:08:00] I/launcher - Running 1 instances of WebDriver
[08:08:00] I/direct - Using ChromeDriver directly...
[08:08:02] E/launcher - Error: TypeError: Cannot read property 'PRETTY' of undefined
    at onPrepare (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/apps/my-app-e2e/protractor.conf.js:31:47)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:46:49
    at Function.promise (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:682:9)
    at Object.runFilenameOrFn_ (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:38:16)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/runner.js:98:27
    at _fulfilled (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:834:54)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:796:13)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:556:49
    at runSingle (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:137:13)

Expected Behavior

Protractor e2e tests on a newly generated Nrwl Angular application should succeed.

Steps to Reproduce

npx create-nx-workspace my-org
cd my-org
yarn add -D -E @nrwl/angular
nx g @nrwl/angular:init
# Make sure to choose Protractor as the e2e test runner
nx g @nrwl/angular:app my-app
nx e2e my-app-e2e

Failure Logs

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
: Compiled successfully.
[08:01:26] I/launcher - Running 1 instances of WebDriver
[08:01:26] I/direct - Using ChromeDriver directly...
[08:01:27] E/launcher - Error: TSError: ⨯ Unable to compile TypeScript:
error TS5083: Cannot read file '/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/tsconfig.json'.

    at createTSError (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/ts-node/src/index.ts:261:12)
    at Object.register (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/ts-node/src/index.ts:265:42)
    at onPrepare (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/apps/my-app-e2e/protractor.conf.js:25:24)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:46:49
    at Function.promise (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:682:9)
    at Object.runFilenameOrFn_ (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:38:16)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/runner.js:98:27
    at _fulfilled (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:834:54)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:796:13)
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
: Compiled successfully.
[08:08:00] I/launcher - Running 1 instances of WebDriver
[08:08:00] I/direct - Using ChromeDriver directly...
[08:08:02] E/launcher - Error: TypeError: Cannot read property 'PRETTY' of undefined
    at onPrepare (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/apps/my-app-e2e/protractor.conf.js:31:47)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:46:49
    at Function.promise (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:682:9)
    at Object.runFilenameOrFn_ (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/util.js:38:16)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/built/runner.js:98:27
    at _fulfilled (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:834:54)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:796:13)
    at /Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:556:49
    at runSingle (/Users/devinshoemaker/code/nx/playground/nx-angular-protractor/node_modules/protractor/node_modules/q/q.js:137:13)

Environment

>  NX  Report complete - copy this into the issue template

  nx : Not Found
  @nrwl/angular : 10.3.2
  @nrwl/cli : 10.3.2
  @nrwl/cypress : 10.3.2
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.3.2
  @nrwl/linter : 10.3.2
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.3.2
  @nrwl/web : Not Found
  @nrwl/workspace : 10.3.2
  typescript : 4.0.5
zejji commented 4 years ago

@devinshoemaker - I also ran into this problem. It appears to be owing to some outdated dependencies.

I have a plain vanilla Angular project generated using version 10.1.1 of the Angular CLI and noticed that some of the dependencies in the nwrl Angular template are significantly older than in the plain Angular project.

Anyhow I ended up doing an `npm install --save-dev' of the versions of the devDependencies in the following picture and was able to get it working. I think it's probably just the jasmine-core and jasmine-spec-reporter dependencies that would need updating at an absolute minimum:

image

juristr commented 4 years ago

yep, adjusting the tsconfig.json in the e2e test to point to ../../tsconfig.base.json + upgrading the jasmine-spec-reporter does the job.

I have a fix for it in the pipe soon

devinshoemaker commented 4 years ago

Awesome, thanks!

juristr commented 3 years ago

@devinshoemaker should be released with 10.4.0. Using nx migrate should fix the issue automatically, as well as new workspaces shouldn't have it any more

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.