question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run e2e with multiple devServerTargets

See original GitHub issue

Description

I would like to be able to serve both frontend app and backend api before running e2e tests.

Currently I can serve multiple projects using @nrwl/workspace:run-commands as demonstrated in here: https://github.com/nrwl/nx/issues/1482

But when running e2e tests with devServerTarget set to such a command:

        "serve": {
          "builder": "@nrwl/workspace:run-commands",
          "options": {
            "commands": [
              {
                "command": "nx serve api"
              },
              {
                "command": "nx serve desktop"
              }
            ],
            "parallel": true
          }
        },

it doesn’t start tests because it doesn’t know when serve command is ready 😕

I tried to work it around with:

        "e2e-ci": {
          "builder": "@nrwl/workspace:run-commands",
          "options": {
            "commands": [
              {
                "command": "nx serve desktop-with-api"
              },
              {
                "command": "nx e2e desktop-e2e"
              }
            ],
            "parallel": true
          }
        },

But that fails to complete at the end. And readyWhen doesn’t stop processes.

Motivation

Running test in CI environment.

Suggested Implementation

I don’t know how devServerTarget knows that serve process is ready in the first place.

I image it would have to respond similarly to run-commands.

Alternate Implementations

Perhaps base it on baseUrl (https://github.com/nrwl/nx/issues/1614), but there is still issue of stoping processes.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:21
  • Comments:32 (9 by maintainers)

github_iconTop GitHub Comments

35reactions
barbados-clemenscommented, Feb 18, 2022

Hi all this looks to be something that would be a benefit to have as it’s been referenced by a handful of other issues. I’ll try to take some time to figure out what it will take to make this happen. unsure what the timeline would look like but adding it to my todo list!

20reactions
tfohlmeistercommented, Mar 5, 2021

I found a good solution in the cypress guides using start-server-and-test.

Install dependency: npm install --save-dev start-server-and-test

Add or update your e2e script in package.json: (adapt api:serve and the port to match your BE project and port)

"scripts": {
   "e2e": "start-server-and-test \"nx run api:serve\" http://localhost:3333",
}

Run e2e and server in one command: (the part after – is provided as an argument to start-server-and-test and would start a FE / E2E project of your choice)

npm run e2e -- "nx affected:e2e"

Thats it. I am using this in a Github Action pipeline and it works great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Workspace Settings - E2E Testing Configuration
We need to set the devServerTarget for the production config of the e2e task for the corresponding e2e project. We also need to...
Read more >
@nrwl/cypress:cypress | Nx
Run Cypress for e2e, integration and component testing. ... If devServerTarget is provided, the url returned from started the dev server will be...
Read more >
How to run Protractor e2e tests using different Angular ...
In my case, I want to always run my e2e tests with my dev configuration, so I just changed this line to "devServerTarget": ......
Read more >
Angular CLI - ng e2e Command - Tutorialspoint
workspace-project App √ should display welcome message Executed 1 of 1 spec SUCCESS in 2 secs. ng e2e also opens the browser and...
Read more >
e2e Testing with Cypress.io - WebDave
My goal is to get as many developers as possible interested in tests. What is e2e testing? It is the type of test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found