nx: Cannot run cypress e2e tests for a node app

Current Behavior

The @nrwl/cypress:cypress builder doesn’t seem to work when I pass a node app (which is using the @nrwl/node:node builder) as the devServerTarget. The node app gets compiled and served correctly, but cypress just never starts.

Expected Behavior

After compiling and serving the app, cypress should start testing.

Steps to Reproduce

Create a new node app, create a new e2e app targeting it, and try running it.

Environment

nx report

 >  NX   Report complete - copy this into the issue template

   Node : 14.18.1
   OS   : darwin arm64
   npm  : 6.14.16
   
   nx : 14.2.4
   @nrwl/angular : 14.2.4
   @nrwl/cypress : 14.2.4
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.2.4
   @nrwl/eslint-plugin-nx : 14.2.4
   @nrwl/express : 14.2.4
   @nrwl/jest : 14.2.4
   @nrwl/js : 14.2.4
   @nrwl/linter : 14.2.4
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.2.4
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.2.4
   @nrwl/web : Not Found
   @nrwl/workspace : 14.2.4
   typescript : 4.5.5
   ---------------------------------------
   Community plugins:
   	 @ng-bootstrap/ng-bootstrap: 12.1.2
   	 @ngrx/component-store: 13.2.0
   	 @ngrx/effects: 13.2.0
   	 @ngrx/router-store: 13.2.0
   	 @ngrx/store: 13.2.0
   	 @ngrx/store-devtools: 13.2.0
   	 @nguniversal/common: 13.1.1
   	 @nguniversal/express-engine: 13.1.1
   	 @nguniversal/builders: 13.1.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 34 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Not stale. @ple16 thank you for the example.

We’re still looking for an optimal way to do this.

Hi @nartc,

Yes it does work that way.

I’ve also just seen this pr https://github.com/nrwl/nx/pull/11325 and given that’s it’s switched to using the node executor for a custom server I think that’s possibly going to introduce the issue with cypress being able to serve.

I think I’m going to have a crack at writing a little executor as per https://nx.dev/executors/creating-custom-builders that just calls the node executor but takes an additional prop when I can set the baseUrl and return just see if I can’t trick cypress into running