Executing docker command using nest.js

My question is related to integrating back-end Nest.js code with a running Cypress.js Docker container, while also having a front-end website.

Is there a way for the user's action on the website to trigger a command that communicates with the Docker container and automatically runs tests? I currently use "docker container exec" command manually, but I want this process to be automated.

Answer №1

If you're looking to interact with Docker containers in your Node.js application, consider using the node-docker-api library:

container.exec.create({
    AttachStdout: true,
    AttachStderr: true,
    Cmd: [ 'some', 'related', 'test' ]
})

Alternatively, a more straightforward approach would be:

const {exec}  = require('shelljs')

function executeCommand() {
    const child = exec(`docker container exec some related test`)
    console.log(child.stdout)
}

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

What could be causing the Google OAuth callback to fail upon the initial login attempt on my site?

I have developed a website that allows users to log in with Google. The following code is used to verify if the user has logged in before. If they have, they are simply logged into the site. However, if it's their first time logging in, they are added ...

After pressing the login button, my intention is to transition to a different page

I am relatively new to web development and working with angular. I have a login component that, upon hitting the LOGIN button, should redirect to another component on a different page. However, currently, when I click the button, it loads the data of the o ...

Circular dependency in typescript caused by decorator circular reference

Dealing with a circular dependency issue in my decorators, where the class ThingA has a relation with ThingB and vice versa is causing problems for me. I've looked into various solutions that others have proposed: Beautiful fix for circular depende ...

Leaving the function prematurely without completion of the conditional statement

In my implementation, I have a basic function that invokes a method of a library. However, the issue arises when there is an if statement during execution. The problem I am facing is that my function is being terminated before it exits the if statement. I ...

Break apart the string and transform each element in the array into a number or string using a more specific type inference

I am currently working on a function that has the ability to split a string using a specified separator and then convert the values in the resulting array to either strings or numbers based on the value of the convertTo property. Even when I call this fun ...

explore and view all images within a directory

Hello, I am new to NextJS and encountering some issues. I have a folder in my public directory containing 30 images that I want to import all at once in the simplest way possible, without having to import each image individually by name. Here is the curren ...

Tips for utilizing Swagger UI's responseInterceptor in TypeScript

Working with Swagger UI, I have successfully implemented the following code in jsx with React: <SwaggerUI url={SPEC_FILE} responseInterceptor={(response: Response) => { //console.log("response ", response); if (response.url === R ...

In TypeScript Next.js 14 APP, object literals are limited to declaring existing properties

I encountered an error in my typescript next.js 14 APP. I need assistance resolving this issue, which states: Object literal may only specify known properties, and 'productPackages' does not exist in type '(Without<ProductCreateInput, Pr ...

Guide on enabling external API login with Next Auth v5 in Next.js 14 using the application router

While trying to navigate the documentation for Next Auth, I found myself struggling with outdated examples and an overall lack of clarity. It appears that the documentation is still a work in progress, making it challenging to find reliable information on ...

Configuration of injected services in IONIC 2

I am curious about how the services from injected work in IONIC 2. Specifically, my question is regarding the number of instances that exist when one service is used in two or more controllers. Previously, I asked a colleague who mentioned that IONIC 2 op ...

Using TypeScript TSX with type parameters

Is it possible to define type parameters in TypeScript TSX syntax? For instance, if I have a class Table<T>, can I use something like <Table<Person> data={...} /> ...

What could be causing the getTotals() method to malfunction?

I have been working on a finance app that is designed to update the "income", "expenses", and "balance" tables at the top each time a new item is added by the user. However, the current code seems to be failing in updating these values correctly based on u ...

Waiting for a response in Typescript before running a function

Is there a way to execute a function after the response is completed without using setTimeout()? I am facing an issue with uploading large files where the waiting time is insufficient. this.orderTestService.orderObservable$ .pipe(untilDestroyed(this)) ...

Extract from Document File

After receiving a PDF through an Angular Http request from an external API with Content Type: application/pdf, I need to convert it into a Blob object. However, the conventional methods like let blobFile = new Blob(result) or let blobFile = new Blob([resul ...

Guide on displaying information on a pie chart in Angular 2 using ng2-charts

How can I display data on a pie chart like this? https://i.sstatic.net/WX9ptm.png Like shown in the image below: https://i.sstatic.net/sqlv2m.png <canvas baseChart class="pie" [data]="Data" [labels]="Labels" [colors]="Colors" [chartType]="p ...

Understanding the attribute types in Typescript React

While working on code using Typescript + React, I encountered an error. Whenever I try to set type/value in the attribute of <a> tag, I receive a compile error. <a value='Hello' type='button'>Search</a> This piece o ...

TypeScript compilation error - No overload is compatible with this call

Currently, I am working on a project using TypeScript alongside NodeJS and Express. this.app.listen(port, (err: any) => { if (err) { console.log("err", err) } else { console.log(`Server is listing on port ${port}`); } }); The co ...

Generating an Object Using HttpClient

When working with httpclient, you can specify the type for the get call and receive a struct of that object. For example. http.get<ProductData>("url:ressource:id").subscribe(x=> this.myObj = x) This means that myObj will only appear to ...

Adding new types to a tuple type in TypeScript

My goal is to add types to the elements of a tuple using spread syntax. Here is an example: type A = [a:number,b:string] type B = [...A,c:boolean] The desired result should be type B = [a:number,b:string,c:boolean] However, when I attempted this approac ...

Tips for receiving input on one HTML page and displaying it on the next page using Angular 2

Just started learning Angular 2 and trying to work with data binding. I'm having trouble printing the value from one page to another through components. The code below prints the value on the same page instead of passing it to another page. Can anyone ...