From 13ac6db8d9090e21f348540caa7b7114fda99b86 Mon Sep 17 00:00:00 2001 From: Harshit Pandey Date: Mon, 5 Jun 2023 09:26:06 +0530 Subject: [PATCH] fix: CLI args to run cypress locally in run mode does not work from TestAutomation.md (#23977) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > Updated CLI args in TestAutomation.md to run cypress locally > #### PR fixes following issue(s) Fixes #23798 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- contributions/docs/TestAutomation.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/contributions/docs/TestAutomation.md b/contributions/docs/TestAutomation.md index fad7c37cdc..554cb36d98 100644 --- a/contributions/docs/TestAutomation.md +++ b/contributions/docs/TestAutomation.md @@ -6,15 +6,15 @@ 1. Cypress tests are located in the `app/client/cypress` directory. -1. All the test spec _must_ be in the integration directory only i.e `app/client/cypress/integration` +1. All the test spec _must_ be in the e2e directory only i.e `app/client/cypress/e2e` -1. You can create directories under `app/client/cypress` but make sure you place the spec within the `app/client/cypress/integration` directory. +1. You can create directories under `app/client/cypress` but make sure you place the spec within the `app/client/cypress/e2e` directory. -1. Directory name under `app/client/cypress/integration` suggests the specific area the test belongs to. Example: All our [Regression tests]() are in `app/client/cypress/integration/Regression_TestSuite` +1. Directory name under `app/client/cypress/e2e` suggests the specific area the test belongs to. Example: All our [Regression tests]() are in `app/client/cypress/e2e/Regression` -1. For default settings, check the `app/client/cypress.json` file. +1. For default settings, check the `app/client/cypress.config.ts` file. -1. You can create a local file `app/client/cypress.env.json` to populate `USERNAME` and `PASSWORD` env variables or use one of the methods [from their docs](https://docs.cypress.io/guides/guides/environment-variables.html#Setting). +1. Update file `app/client/cypress.config.ts` to populate `USERNAME` and `PASSWORD` env variables or use one of the methods [from their docs](https://docs.cypress.io/guides/guides/environment-variables.html#Setting). ```json { @@ -23,7 +23,7 @@ } ``` -1. Once the `app/client/cypress.env.json` file is ready, we can actually run tests from the cypress client. +1. Once the `app/client/cypress.config.ts` file is ready, we can actually run tests from the cypress client. 1. Change your directory to `app/client`. @@ -32,13 +32,13 @@ 1. Command to open cypress client `$(npm bin)/cypress open` Cypress supports Chrome/Firefox/electron browsers. Select a suitable browser and check the status of your tests. -1. For run mode, you can use CLI args. Example: To run the entire `Regression_TestSuite`, use `$(npm bin)/cypress run --headless --browser chrome --spec "cypress/integration/Regression_TestSuite/*/*"` +1. For run mode, you can use CLI args. Example: To run the all the tests under `Regression`, use `$(npm bin)/cypress run --headless --browser chrome --spec "cypress/e2e/Regression/*/*"` 1. If you need help with writing the tests, their syntax or flow, cypress [getting started docs](https://docs.cypress.io/guides/core-concepts/introduction-to-cypress#What-you-ll-learn) is a great starting point. ## A word about env variables in Cypress tests -If you want to add a new env variable to cypress tests, add it to the `cypress.env.json` file and also in the documentation above. +If you want to add a new env variable to cypress tests, add it to the `cypress.config.ts` file and also in the documentation above. All ENV variables from your `.env` file and all `APPSMITH_*` env variables from `process.env` are accessible with the `Cypress.env()` method. @@ -49,7 +49,7 @@ All ENV variables from your `.env` file and all `APPSMITH_*` env variables from - Creation of a new test app everytime. We can pass an app id to the test so that it can reuse it and avoid creating a new app everytime. - Skip login if the user is already logged in from previous test run session. - Skip multiple visit to the workspace page if a test uses DSL for loading fixtures. If a test uses DSL, a visit to the workspace is mandatory. Thus avoiding multiple visits to the workspace page saves time during test run. - - To enable rapid mode for your test, you can add following configuration to your `cypress.env.json` file created above, + - To enable rapid mode for your test, you can add following configuration to your `cypress.config.ts` file created above, ``` "RAPID_MODE": { "enabled" : true, // Set it to true to enable rapid mode, otherwise set it to false