Expand my Community achievements bar.

SOLVED

How to run/execute the cypress in AEM 6.5.19

Avatar

Level 3

Hi,

I have created the AEM Cypress project for AEM 6.5.19 and gave the build mvn clean install. After that i deploy the code on AEM 6.5.19. Is there a way to run the Cypress ui.tests automatically without manually executing the commands using by going to the respective ui.tests/test-module folder "npm test" or npx cypress open.

 

Please help me how to execute the ui.tests automatically.

 

Thanks & Regards,

Kalyan

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I think you can use frontend maven plugin to achieve this. https://github.com/eirslett/frontend-maven-plugin 
You will have to configure it in your ui.tests maven module's pom similar to how it is configured in ui.frontend module. Sample to wknd github 
https://github.com/adobe/aem-guides-wknd/blob/main/ui.frontend/pom.xml#L44
Parent pom's reference for node installation https://github.com/adobe/aem-guides-wknd/blob/main/pom.xml#L175 
Disclaimer : I have not tried this personally  

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @kalyanchakravarthych ,

To execute Cypress UI tests automatically in AEM 6.5.19, you can integrate Cypress with your build and deployment process. Here's a general outline of the steps you can follow:

1. Configure Cypress in your AEM project: Make sure you have set up Cypress correctly in your AEM project. This involves installing Cypress as a dev dependency and configuring the necessary scripts and configurations in your project's package.json file.

2. Create a build script: In your project's build script (e.g., Maven or Gradle), add a step to execute the Cypress tests. This can be done by invoking the Cypress CLI commands, such as `npx cypress run` or `npm test`, depending on your setup.

3. Configure the build pipeline: If you are using a CI/CD tool like Jenkins, configure your build pipeline to execute the build script that includes the Cypress test execution step. This will ensure that the tests are automatically executed during the build process.

4. Monitor test results: After the build is triggered, monitor the test results to check for any failures or issues. You can configure your CI/CD tool to notify you or your team about the test results.

By integrating Cypress into your build and deployment process, you can automate the execution of UI tests without manually running the commands. This allows for continuous testing and helps catch any issues early in the development cycle.

Note: The specific implementation details may vary depending on your project's setup and CI/CD tool. Make sure to refer to the documentation of your CI/CD tool and Cypress for more detailed instructions on integration.

Avatar

Community Advisor

Hi, 

You could try to configure the frontend-maven-plugin in the ui.tests to run the command you need upon the mvn clean install. You can check how the plugin is configured in the ui.apps/pom.xml to give you an idea.

Hope this helps.



Esteban Bustamante

Avatar

Correct answer by
Community Advisor

I think you can use frontend maven plugin to achieve this. https://github.com/eirslett/frontend-maven-plugin 
You will have to configure it in your ui.tests maven module's pom similar to how it is configured in ui.frontend module. Sample to wknd github 
https://github.com/adobe/aem-guides-wknd/blob/main/ui.frontend/pom.xml#L44
Parent pom's reference for node installation https://github.com/adobe/aem-guides-wknd/blob/main/pom.xml#L175 
Disclaimer : I have not tried this personally  

Avatar

Community Advisor

Very simple, since you already cypress installed into your project, we will skip instructions for how to set that up. Assuming that you already have npm run cypress working, lets move ahead. You should edit the pom.xml within the ui.frontend to run something like npm run cypress && npm run prod. Once if there's an error, during the maven build, everything should be escaped, and the code would not continue to compile.

 

Under the ui.frontend/pom.xml, you should be able to find the frontend-maven-plugin, which you can add the code change, look into line:56 here https://github.com/adobe/aem-project-archetype/blob/develop/src/main/archetype/ui.frontend.general/p...

I would adjust it to

 <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>npm run cyprus</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run cyprus</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run prod</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run prod</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

 

Avatar

Administrator

@kalyanchakravarthych Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni