From 9072e287aabf7e5df2edd81f6ce114a5dc43e703 Mon Sep 17 00:00:00 2001 From: Tyler Ohlsen Date: Tue, 18 Jul 2023 12:52:02 -0700 Subject: [PATCH] Add to README Signed-off-by: Tyler Ohlsen --- DEVELOPER_GUIDE.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 097fce232..27076778b 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -25,7 +25,7 @@ You should have a running instance of OpenSearch Dashboards to run these tests a ### Installation -To install the dependencies run +To install the dependencies run ``` npm install @@ -83,7 +83,7 @@ with security: $ yarn cypress run-with-security --spec "cypress/integration/core-opensearch-dashboards/opensearch-dashboards/*.js" ``` -These tests run in headless mode by default. +These tests run in headless mode by default. And you can override certain [cypress config or environment variable](cypress.json) by applying additional cli arguments, for example to override the baseUrl and openSearchUrl to test a remote OpenSearch endpoint: @@ -97,7 +97,6 @@ $ yarn cypress run --spec "cypress/integration/core-opensearch-dashboards/opense `MANAGED_SERVICE_ENDPOINT`: set to true if tests are running against managed service domains. - ## Writing tests The testing library uses [Cypress](https://www.cypress.io/) as its testing framework and follow its high level folder structure. All tests are written under the `./cypress/integration` folder. @@ -123,6 +122,13 @@ Tests for plugins that are not a part of the [OpenSearch Dashboards](https://git /plugins / ``` + +### Tests with snapshots + +[cypress-image-snapshot](https://github.com/jaredpalmer/cypress-image-snapshot) is a visual regression testing framework that can be used to persist snapshots & compare against them during test runs. This is very useful for checking elements that may not allow for easy validation via HTML elements, such as Vega visualizations which are a single black-box `canvas` element. + +When writing new tests, to take a snapshot, you can pass the flag `--env updateSnapshots=true` into the command. This will take snapshots and store them under the `snapshots/` directory. To do comparisons against the snapshots later on, simply run without the flag. For further details, see the GitHub repository linked above. + ### Experimental Features When writing tests for experimental features, please follow these steps. @@ -144,6 +150,7 @@ Create a new workflow by referring to [this template](https://github.com/opensea To make the build repo enable your experimental feature when spinning up OSD service, make sure that you update [this file](https://github.com/opensearch-project/opensearch-build/blob/main/src/test_workflow/integ_test/service_opensearch_dashboards.py) You could either modify the start command or the yml file. To avoid a potentially long start command, it is preferred to modify the yml file to turn on the feature. ## General + ### Formatting `prettier` and `ESLint` is integrated and used to standardize formatting of files, where `prettier` takes care of the code formatting and `ESLint` takes care of the code style. You can check the formatting of all files (new and existing) by running @@ -151,9 +158,11 @@ To make the build repo enable your experimental feature when spinning up OSD ser ``` $ yarn lint ``` + and auto fix the formatting of all files (new and existing) by running + ``` $ yarn lint --fix ``` -`Husky` precommit hook is used to automatically run `yarn lint`, please fix the files according to lint result before commiting code changes (run `yarn lint --fix` for fixable errors, or manully fix code according to error messages). If you have any doubts on `ESLint` rules, feel free to [open an issue](issues). \ No newline at end of file +`Husky` precommit hook is used to automatically run `yarn lint`, please fix the files according to lint result before commiting code changes (run `yarn lint --fix` for fixable errors, or manully fix code according to error messages). If you have any doubts on `ESLint` rules, feel free to [open an issue](issues).