Skip to content

Commit

Permalink
build(deps-dev): update cypress to 5.5.0, improvements for running lo…
Browse files Browse the repository at this point in the history
…cally (apache#11603)

* reduce numTestsKeptInMemory to 0 to prevent Chrome OOM crash

* Add cypress-run-chrome script, update docs and cypress_build.sh

* Upgrade Cypress to latest version

* tox: add missing 'cypress' env, cleanup flask server

* Fix failing dashboard edit test syntax

* Reduce retry count to 1

* Prettier test
  • Loading branch information
robdiciuccio authored and auxten committed Nov 20, 2020
1 parent 34648f6 commit e53a89f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 68 deletions.
18 changes: 11 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,32 +624,36 @@ We use [Cypress](https://www.cypress.io/) for integration tests. Tests can be ru

```bash
export SUPERSET_CONFIG=tests.superset_test_config
export SUPERSET_TESTENV=true
export ENABLE_REACT_CRUD_VIEWS=true
export CYPRESS_BASE_URL="http://localhost:8081"
superset db upgrade
superset init
superset load_test_users
superset load_examples
superset load_examples --load-test-data
superset init
superset run --port 8081
```

Run Cypress tests:

```bash
cd superset-frontend
npm run build
npm run build-instrumented

cd cypress-base
npm install
npm run cypress run

# run tests via headless Chrome browser (requires Chrome 64+)
npm run cypress-run-chrome

# run tests from a specific file
npm run cypress run -- --spec cypress/integration/explore/link.test.js
npm run cypress-run-chrome -- --spec cypress/integration/explore/link.test.js

# run specific file with video capture
npm run cypress run -- --spec cypress/integration/dashboard/index.test.js --config video=true
npm run cypress-run-chrome -- --spec cypress/integration/dashboard/index.test.js --config video=true

# to open the cypress ui
npm run cypress open
npm run cypress-debug

# to point cypress to a url other than the default (http://localhost:8088) set the environment variable before running the script
# e.g., CYPRESS_BASE_URL="http://localhost:9000"
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/cypress-base/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"baseUrl": "http://localhost:8088",
"chromeWebSecurity": false,
"defaultCommandTimeout": 5000,
"numTestsKeptInMemory": 0,
"experimentalFetchPolyfill": true,
"requestTimeout": 10000,
"ignoreTestFiles": [
Expand All @@ -13,7 +14,7 @@
"viewportHeight": 1024,
"projectId": "ukwxzo",
"retries": {
"runMode": 2,
"runMode": 1,
"openMode": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ describe('Dashboard edit mode', () => {
});

cy.get('[data-test="dashboard-builder-component-pane-tabs-navigation"]')
.within(() => {
cy.get('.ant-tabs-tab').last();
})
.find('.ant-tabs-tab')
.last()
.click();

// find box plot is available from list
Expand Down
66 changes: 32 additions & 34 deletions superset-frontend/cypress-base/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion superset-frontend/cypress-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "run cypress against superset",
"scripts": {
"cypress": "cypress",
"cypress-run-chrome": "cypress run --browser chrome --headless",
"cypress-debug": "cypress open --config watchForFileChanges=true"
},
"author": "Apcahe",
Expand All @@ -14,7 +15,7 @@
"shortid": "^2.2.15"
},
"devDependencies": {
"cypress": "5.0.0",
"cypress": "^5.5.0",
"eslint-plugin-cypress": "^2.11.1"
}
}
9 changes: 6 additions & 3 deletions superset-frontend/cypress_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ echo "[completed js build steps]"
cd cypress-base
time npm ci
export CYPRESS_BASE_URL="http://localhost:${PORT}"
CYPRESS_PATH='cypress/integration/'${1}'/*'
time npm run cypress run -- --spec "$CYPRESS_PATH" --record false --config video=false

if [ -n "$1" ]; then
CYPRESS_PATH='cypress/integration/'${1}'/*'
time npm run cypress-run-chrome -- --spec "$CYPRESS_PATH" --record false --config video=false || true
else
time npm run cypress-run-chrome -- --record false --config video=false || true
fi
kill %1
63 changes: 44 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Remember to start celery workers to run celery tests, e.g.
# celery worker --app=superset.tasks.celery_app:app -Ofair -c 2
[testenv]
basepython = python3.8
ignore_basepython_conflict = true
commands =
superset db upgrade
superset init
Expand All @@ -44,56 +46,79 @@ setenv =
# make sure that directory is accessible by docker
hive: UPLOAD_FOLDER = /tmp/.superset/app/static/uploads/
usedevelop = true
whitelist_externals =
allowlist_externals =
npm
pkill

[testenv:cypress-dashboard]
[testenv:cypress]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh dashboard
deps =
-rrequirements/testing.txt
{toxinidir}/superset-frontend/cypress_build.sh
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-dashboard]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh dashboard
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-explore]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh explore
deps =
-rrequirements/testing.txt
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-sqllab]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}

[testenv:cypress-sqllab]
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh sqllab
deps =
-rrequirements/testing.txt
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:cypress-sqllab-backend-persist]
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_TESTENV = true
SUPERSET_CONFIG = tests.superset_test_config
SUPERSET_HOME = {envtmpdir}

[testenv:cypress-sqllab-backend-persist]
ENABLE_REACT_CRUD_VIEWS = true
commands =
npm install -g npm@'>=6.5.0'
pip install -e {toxinidir}/
{toxinidir}/superset-frontend/cypress_build.sh sqllab
deps =
-rrequirements/testing.txt
setenv =
PYTHONPATH = {toxinidir}
SUPERSET_CONFIG = tests.superset_test_config_sqllab_backend_persist
SUPERSET_HOME = {envtmpdir}
commands_post =
pkill -if "python {envbindir}/flask"

[testenv:eslint]
changedir = {toxinidir}/superset-frontend
Expand Down

0 comments on commit e53a89f

Please sign in to comment.