What is the process for configuring ng e2e to run on a specific port?

Ever since moving to Angular 6, I've noticed that ng e2e is no longer able to run on an available port like it used to. In the past, when we were using Angular 4, the app service would be on port 4200 and running ng e2e would automatically select a free port (such as 49152) for testing.

However, after upgrading to Angular 6, trying to perform tests in the same setup results in an error message stating "Port 4200 is already in use". It seems like something went wrong during the upgrade process.

I'm hesitant to manually specify a port number using --port {port number} for CI purposes, as hardcoding ports can create issues with parallel executions in CI. Should I consider modifying the configuration settings following the upgrade to Angular 6?

Answer №1

After some investigation, I managed to discover the solution.

To initiate the process, simply execute ng e2e <app-name> --port 0 and allow it to run on any available ports.

By running this particular command, the tests will automatically search for open ports in the event of parallel execution. There is no need to manually specify or input port numbers every time.

Answer №2

Dealing with a comparable issue, I found a workaround that might help you out: Inside your package.json file, specifically in the scripts section, consider adding "e2e": ng e2e --port number. After doing so, you can then run the command npm run e2e from the terminal.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The challenge of determining the best approach for creating local routes and resolving conflicts

The routes in my code are defined as follows @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) export class CartRoutingModule implements Resolve<ServiceCart> { constructor(private service: CartService) {} re ...

Facing issues with query parameters functionality

For my Angular2 application, I need to include some optional parameters in a route. Since they are not mandatory, I have opted to utilize the queryParams feature. This is the code snippet I am using to pass the optional argument: public recoverPassword() ...

Determine in JavaScript if one date occurs exactly one week after another date

Currently, I am tackling a date comparison task for our application. The main objective is to compare the Start Date inputted by the user with the Operator/Region Effective Date, which signifies when a new list of product prices becomes valid. Our aim is t ...

What is the best way to trigger a 'Save As' dialog box on a browser when a button is activated within an Angular application, guaranteeing cross-browser compatibility?

The solution needs to be compatible with both Windows and Mac operating systems. Additionally, we should be able to specify a default file name and type. ...

Error in ng2-translate: TranslatePipe.transform cannot access the property 'subscribe' as it is undefined

I have been utilizing ng2-translate within my Angular 5 project and I am currently in the process of setting up a unit test for a specific component. Typically, I import TranslateModule.forRoot( *...* ) in my Tests and everything runs smoothly when using t ...

Creating multiple maps in Angular 4 using Mapbox with a loop (ngFor)

Creating multiple maps using *ngFor requires the component div id to be ready before assigning it to mapbox's container variable. Otherwise, an error stating that the map id is not defined will occur if setTimeout is not used. The HTML for my compone ...

Automating the recording of performance using Chrome DevTools' timeline feature

In my current endeavor, I am focused on creating valuable performance tests for an Angular application. For e2e testing, I rely on protractor and currently utilize protractor-perf. While this tool is effective in pinpointing performance issues, it falls ...

Is there a way to verify if multiple variables in Typescript are null or undefined?

Background To address the issue of checking whether a specific variable is null or undefined, I created the isNullish function. The implementation of this function is shown below. type Nullish = null | undefined; const isNullish = (target: unknown): targe ...

Enhance the express Response type and then export my updated type as a distinct module

I am currently working on developing a new 'common' module for my team. One of the key features it should have is an extension of both the response and request objects in Express. Our main goal is to achieve two things - first, extending the Req ...

Tips on how to increase and update the index value by 2 within an ngFor loop while maintaining a fixed format

I have a specific template layout that displays only two items in each row as shown below. I want to use the ngFor directive to iterate through them: <div class="row" *ngFor="let item of cityCodes; let i = index"> <div class="col-6" (click)= ...

Clicking the button in Angular should trigger a series of functions to be

It seems like I'm struggling with a simple question due to my lack of experience in this area. Any guidance or help would be greatly appreciated. I have a button that should trigger multiple functions when clicked, all defined in the same ts file. Wh ...

Why is it that PowerShell cannot execute Angular commands?

Recently, I started diving into Angular and encountered an issue using PowerShell in Windows. Every time I run an angular command like: ng new new-app or ng serve I keep getting this error message: ng : File C:\Users\< username >\ ...

How to use Angular 8 Form Builder to upload an array of multiple images

My product form includes various fields like product name, description, and an array of images. Product Form Product Name - Product Description Product Purity - Product Commodity Images (Add) Checkbox 1 - Image 1 Checkbox 2 - Image 2 Checkbox 3 - ...

Checking if a useState setter passed in props is triggered in a Jest test

In a React component, I have the following functions: const changeOrder => { a websocket request }; const handleArrow = async () => { const res = await changeOrder(side, headingOrder, config); if (res !== undefined) setOrder(res); }; The se ...

Retrieve data from a Firestore document in an Ionic application

I have a service that retrieves a specific document from Firestore using the getBidremains method. The method in the TypeScript class is called in ngOnInit like this: this.userInfo = this.firestoreService.getBidremains(userId).valueChanges().subscribe(da ...

Transforming Typescript Strings into ##,## Format

As I've been using a method to convert strings into ##,## format, I can't help but wonder if there's an easier way to achieve the same result. Any suggestions? return new Intl.NumberFormat('de-DE', { minimumFractionDigits: 2, max ...

Automatically convert TypeScript packages from another workspace in Turborepo with transpilation

I have set up a Turborepo-based monorepo with my primary TypeScript application named @myscope/tsapp. This application utilizes another TypeScript package within the same repository called @myscope/tspackage. For reference, you can view the example reposit ...

Vue Error: The method "reduce" is not a function

Currently implementing Vue.js with Typescript and aiming to utilize reduce for summing up the values of desktopCnt and mobileCnt from the deviceCount array to display their total numbers. The deviceCount array structure is as follows: [ { " ...

Angular component with @Input() directive allows data to be passed into

I am curious about how the @Input property's rendering works internally. In Angular, if I create a component with type and title as @Input properties, how does the component know that the value of the type property should be treated as a string, whil ...

I can't figure out why this Angular code for an Ionic alert isn't functioning properly

async displayNotification() { const notification = await this.notificationController.create({ header: 'Notification', subHeader: 'Additional Info', message: 'This is a notification message.', button ...