From e8c22f31b4d0b3290ccd94992369b47cae6ebb6e Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 19:34:43 +0200 Subject: [PATCH 01/22] remove config json Signed-off-by: Jakub Mucha --- tests/e2e/config.json | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 tests/e2e/config.json diff --git a/tests/e2e/config.json b/tests/e2e/config.json deleted file mode 100644 index 11d3c247a..000000000 --- a/tests/e2e/config.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "baseUrl": "http://localhost:3000", - "userAgent": "synpress", - "retries": { "runMode": 0, "openMode": 0 }, - "integrationFolder": "tests/e2e/specs", - "screenshotsFolder": "tests/e2e/screenshots", - "videosFolder": "tests/e2e/videos", - "chromeWebSecurity": true, - "viewportWidth": 1366, - "viewportHeight": 768, - "component": { - "componentFolder": ".", - "testFiles": "**/*spec.{js,jsx,ts,tsx}" - }, - "env": { - "coverage": false - }, - "defaultCommandTimeout": 30000, - "pageLoadTimeout": 30000, - "requestTimeout": 30000 -} From de6d5d9e848c04d2523ccb04760132e807ea8210 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 19:51:52 +0200 Subject: [PATCH 02/22] prettier update Signed-off-by: Jakub Mucha --- .prettierrc.js | 8 -------- .prettierrc.yaml | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 .prettierrc.js create mode 100644 .prettierrc.yaml diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index a873ca7a7..000000000 --- a/.prettierrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - semi: true, - trailingComma: 'all', - singleQuote: true, - printWidth: 80, - tabWidth: 2, - arrowParens: 'avoid', -}; diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 000000000..55126634a --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,7 @@ +semi: true +trailingComma: all +singleQuote: true +printWidth: 80 +tabWidth: 2 +arrowParens: avoid +proseWrap: always From ea95f931330908c1dd79f0cce0eb56df585cf58a Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 19:53:15 +0200 Subject: [PATCH 03/22] init trunk Signed-off-by: Jakub Mucha --- .trunk/.gitignore | 4 ++++ .trunk/trunk.yaml | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .trunk/.gitignore create mode 100644 .trunk/trunk.yaml diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 000000000..203835328 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,4 @@ +*out +*logs +plugins +user_trunk.yaml diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 000000000..9814eb383 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,26 @@ +version: 0.1 +cli: + version: 0.16.1-beta + sha256: + darwin_arm64: 3fb733a9907ec366d86d06313d1b0c956a0f9e86cdbaeaaa72ecf29fb9de17a7 + darwin_x86_64: d15589aaf2128d4a732f96f101ccfad433532d2027a9b809c74169371c7e270e + linux_x86_64: 87245d043c5f0c9bf5b21ff66a43df715f459068bd2e47964c7d517cca074007 +lint: + enabled: + - actionlint@1.6.17 + - eslint@8.23.0 + - git-diff-check@SYSTEM + - gitleaks@8.11.2 + - markdownlint@0.32.2 + - prettier@2.7.1 + ignore: + - linters: [ALL] + paths: + - node_modules/** + - tests/test-dapp + - downloads + - tests/e2e/videos + - tests/e2e/screenshots + threshold: + - linters: [ALL] + level: high From 39c931dce725d04b7563bc79ae6a98d967fbcfd5 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 19:53:24 +0200 Subject: [PATCH 04/22] chore: markdown lint Signed-off-by: Jakub Mucha --- .markdownlint.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .markdownlint.yaml diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 000000000..fb940393d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,10 @@ +# Autoformatter friendly markdownlint config (all formatting rules disabled) +default: true +blank_lines: false +bullet: false +html: false +indentation: false +line_length: false +spaces: false +url: false +whitespace: false From 8db087050f6e89591ea1793de6f3a4d6716a9632 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 19:56:30 +0200 Subject: [PATCH 05/22] indent fixes Signed-off-by: Jakub Mucha --- .github/dependabot.yml | 32 +++---- .github/workflows/audit_and_lint.yml | 21 ++++- .github/workflows/release.yml | 4 +- README.md | 136 +++++++++++++++++++-------- fixtures/example.json | 2 +- support/index.d.ts | 5 +- 6 files changed, 138 insertions(+), 62 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 80c39f74d..1f61f68aa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,25 +1,25 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: - interval: "daily" + interval: 'daily' - - package-ecosystem: "npm" - directory: "/" + - package-ecosystem: 'npm' + directory: '/' schedule: - interval: "daily" + interval: 'daily' open-pull-requests-limit: 5 - target-branch: "dev" + target-branch: 'dev' allow: - - dependency-name: "cypress" - dependency-type: "production" - - dependency-name: "synthetix-*" - dependency-type: "production" - - dependency-name: "@synthetixio/*" - dependency-type: "production" + - dependency-name: 'cypress' + dependency-type: 'production' + - dependency-name: 'synthetix-*' + dependency-type: 'production' + - dependency-name: '@synthetixio/*' + dependency-type: 'production' labels: - - "npm" - - "dependencies" + - 'npm' + - 'dependencies' pull-request-branch-name: - separator: "-" + separator: '-' diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 349783be0..342ecf275 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -8,7 +8,9 @@ on: jobs: audit: # run only on master/dev branch and pull requests - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' + if: + github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || + github.event_name == 'pull_request' runs-on: ubuntu-latest container: @@ -25,12 +27,17 @@ jobs: run: npm audit --audit-level=critical - name: Lockfile lint - run: lockfile-lint -p package-lock.json --type npm --allowed-hosts npm github.com --allowed-schemes "https:" "git+ssh:" --empty-hostname false + run: + lockfile-lint -p package-lock.json --type npm --allowed-hosts npm + github.com --allowed-schemes "https:" "git+ssh:" --empty-hostname + false build: needs: audit # run only on audit success or audit skipped - if: always() && (needs.audit.result == 'success' || needs.audit.result == 'skipped') + if: + always() && (needs.audit.result == 'success' || needs.audit.result == + 'skipped') runs-on: ubuntu-latest container: @@ -66,12 +73,16 @@ jobs: - name: Lint # run only on master/dev branch and pull requests - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' + if: + github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || + github.event_name == 'pull_request' run: npm run lint:sarif - name: Upload lint results # run if lint failed and only on master/dev branch and pull requests - if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request') + if: + always() && (github.ref == 'refs/heads/master' || github.ref == + 'refs/heads/dev' || github.event_name == 'pull_request') uses: github/codeql-action/upload-sarif@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20210517 with: sarif_file: lint-results.sarif diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de039e3f4..0641e6721 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,9 @@ jobs: path: | .npm-cache node_modules - key: ${{ runner.os }}-ubuntu-node-16-${{ hashFiles('**/package-lock.json') }} + key: + ${{ runner.os }}-ubuntu-node-16-${{ + hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-ubuntu-node-16- continue-on-error: true diff --git a/README.md b/README.md index 30cdb01ff..e01619958 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Release CI](https://github.com/Synthetixio/synpress/actions/workflows/release.yml/badge.svg?branch=master)](https://github.com/Synthetixio/synpress/actions/workflows/release.yml) [![Discord](https://img.shields.io/discord/961408653502599171.svg?color=768AD4&label=discord&logo=https%3A%2F%2Fdiscordapp.com%2Fassets%2F8c9701b98ad4372b58f13fd9f65f966e.svg)](https://discordapp.com/channels/961408653502599171/) [![Twitter Follow](https://img.shields.io/twitter/follow/synpress_.svg?label=Synpress_&style=social)](https://twitter.com/Synpress_) + #

@@ -12,30 +13,45 @@ # -[Synpress](https://github.com/Synthetixio/synpress) is a wrapper around [Cypress.io](https://github.com/cypress-io/cypress) with [metamask](https://metamask.io/) support thanks to [puppeteer](https://github.com/puppeteer/puppeteer). +[Synpress](https://github.com/Synthetixio/synpress) is a wrapper around +[Cypress.io](https://github.com/cypress-io/cypress) with +[metamask](https://metamask.io/) support thanks to +[puppeteer](https://github.com/puppeteer/puppeteer). -Synpress makes sure to always use latest version of metamask before tests are ran. +Synpress makes sure to always use latest version of metamask before tests are +ran. It also provides an easy way to use metamask straight from your e2e tests. -For usage examples, feel free to take a look at [kwenta](https://github.com/kwenta/kwenta/tree/master/tests/e2e), [staking](https://github.com/Synthetixio/staking/tree/master/tests/e2e) or [synpress](https://github.com/Synthetixio/synpress/tree/master/tests/e2e) repository. +For usage examples, feel free to take a look at +[kwenta](https://github.com/kwenta/kwenta/tree/master/tests/e2e), +[staking](https://github.com/Synthetixio/staking/tree/master/tests/e2e) or +[synpress](https://github.com/Synthetixio/synpress/tree/master/tests/e2e) +repository. -For additional custom commands and their examples, [check here](https://github.com/synthetixio/synpress/blob/master/support/index.d.ts). +For additional custom commands and their examples, +[check here](https://github.com/synthetixio/synpress/blob/master/support/index.d.ts). -To see in which direction Synpress is headed to, take a look at this [planning board](https://github.com/orgs/Synthetixio/projects/14). +To see in which direction Synpress is headed to, take a look at this +[planning board](https://github.com/orgs/Synthetixio/projects/14). **Features:** - metamask support -- ability to use latest metamask or lock it's version to avoid unexpected failures related to metamask update +- ability to use latest metamask or lock it's version to avoid unexpected + failures related to metamask update - supports multi-lang of metamask, it doesn't depend on any labels -- synpress is fully [tested](https://github.com/Synthetixio/synpress/tree/dev/tests/e2e/specs) +- synpress is fully + [tested](https://github.com/Synthetixio/synpress/tree/dev/tests/e2e/specs) - automatically waits for all XHR requests to be finished before tests are run -- ability to fail e2e tests if there are any browser console error found during test run +- ability to fail e2e tests if there are any browser console error found during + test run - types support for all additional custom commands - the best possible options set up in place to avoid flakiness -- etherscan API helpers in place which for ex. allows to compare your transaction results with etherscan and check tx status -- synthetix helpers in place which allows to interact with synthetix protocol programatically +- etherscan API helpers in place which for ex. allows to compare your + transaction results with etherscan and check tx status +- synthetix helpers in place which allows to interact with synthetix protocol + programatically ## ๐Ÿ‘ท Example setup for eslint and tsconfig @@ -58,10 +74,13 @@ project_dir ```js const path = require('path'); -const synpressPath = path.join(process.cwd(), '/node_modules/@synthetixio/synpress'); +const synpressPath = path.join( + process.cwd(), + '/node_modules/@synthetixio/synpress', +); module.exports = { - extends: `${synpressPath}/.eslintrc.js`, + extends: `${synpressPath}/.eslintrc.js`, }; ``` @@ -69,40 +88,62 @@ module.exports = { ```json { - "compilerOptions": { - "allowJs": true, - "baseUrl": "../../node_modules", - "types": ["cypress", "@types/puppeteer-core", "@synthetixio/synpress/support", "cypress-wait-until", "@testing-library/cypress"], - "outDir": "./output" - }, - "include": ["**/*.*"] + "compilerOptions": { + "allowJs": true, + "baseUrl": "../../node_modules", + "types": [ + "cypress", + "@types/puppeteer-core", + "@synthetixio/synpress/support", + "cypress-wait-until", + "@testing-library/cypress" + ], + "outDir": "./output" + }, + "include": ["**/*.*"] } ``` 3. You're done! ๐ŸŽ‰ -If you would like to use custom paths for your tests and configs, feel free to mirror [default synpress config](https://github.com/Synthetixio/synpress/blob/dev/synpress.json) and modify it for your needs. Then you can direct synpress to use it with `--configFile` flag. +If you would like to use custom paths for your tests and configs, feel free to +mirror +[default synpress config](https://github.com/Synthetixio/synpress/blob/dev/synpress.json) +and modify it for your needs. Then you can direct synpress to use it with +`--configFile` flag. For example: `synpress run --configFile __tests__/e2e/customConfig.json` ## โšก Important -Synpress doesn't seem to communicate with metamask properly if `"chromeWebSecurity": false` flag is set. More about it [here](https://github.com/Synthetixio/synpress/issues/17). +Synpress doesn't seem to communicate with metamask properly if +`"chromeWebSecurity": false` flag is set. More about it +[here](https://github.com/Synthetixio/synpress/issues/17). -Tests work only in headed mode because extensions are not supported in headless mode in [puppeteer](https://github.com/puppeteer/puppeteer/issues/659) and [Cypress](https://docs.cypress.io/api/plugins/browser-launch-api.html#Add-browser-extensions). It's intended to be used in conjunction with `xvfb` on CI. +Tests work only in headed mode because extensions are not supported in headless +mode in [puppeteer](https://github.com/puppeteer/puppeteer/issues/659) and +[Cypress](https://docs.cypress.io/api/plugins/browser-launch-api.html#Add-browser-extensions). +It's intended to be used in conjunction with `xvfb` on CI. -There is a global [`before()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L25) which runs metamask setup before all tests: +There is a global +[`before()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L25) +which runs metamask setup before all tests: - passes welcome page - imports wallet -- changes network (defaults to `kovan`) or creates custom network and changes to it (depending on your setup) +- changes network (defaults to `kovan`) or creates custom network and changes to + it (depending on your setup) - switches back to Cypress window and starts testing -It requires environmental variable called `SECRET_WORDS` to be present in following format => `'word1, word2, etc..'` or private key in an environmental variable called `PRIVATE_KEY`. +It requires environmental variable called `SECRET_WORDS` to be present in +following format => `'word1, word2, etc..'` or private key in an environmental +variable called `PRIVATE_KEY`. -To change default network (`kovan`), you can use `NETWORK_NAME` environmental variable, for example: `NETWORK_NAME=rinkeby`. +To change default network (`kovan`), you can use `NETWORK_NAME` environmental +variable, for example: `NETWORK_NAME=rinkeby`. -Available choices are: `mainnet`, `ropsten`, `kovan`, `rinkeby`, `goerli` and `localhost`. +Available choices are: `mainnet`, `ropsten`, `kovan`, `rinkeby`, `goerli` and +`localhost`. To create and switch to custom network at metamask setup phase, use these: @@ -113,26 +154,42 @@ To create and switch to custom network at metamask setup phase, use these: 5. `BLOCK_EXPLORER` (optional) => ex: `https://synthetix-explorer.io` 6. `IS_TESTNET` (optional) => ex: `false` -Metamask version is hardcoded and frequently updated under supervision to avoid a case when e2e tests break because of CSS classes changes in new version, so all you need is to keep synpress updated in your project. However, you can still override metamask with `METAMASK_VERSION` environmental variable, for example: `METAMASK_VERSION=9.3.0` or `METAMASK_VERSION=latest`. +Metamask version is hardcoded and frequently updated under supervision to avoid +a case when e2e tests break because of CSS classes changes in new version, so +all you need is to keep synpress updated in your project. However, you can still +override metamask with `METAMASK_VERSION` environmental variable, for example: +`METAMASK_VERSION=9.3.0` or `METAMASK_VERSION=latest`. -If you don't want to use environmental variables, you can modify [`setupMetamask()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L26) to following: +If you don't want to use environmental variables, you can modify +[`setupMetamask()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L26) +to following: -`setupMetamask(secretWordsOrPrivateKey, network, password)`, for example: `setupMetamask('word1, word2, etc..', 'mainnet', 'password')`. +`setupMetamask(secretWordsOrPrivateKey, network, password)`, for example: +`setupMetamask('word1, word2, etc..', 'mainnet', 'password')`. -You can also add and switch to custom network by passing an `object` instead of `string` inside `setupMetamask(secretWordsOrPrivateKey, network, password)` function for `network` parameter. +You can also add and switch to custom network by passing an `object` instead of +`string` inside `setupMetamask(secretWordsOrPrivateKey, network, password)` +function for `network` parameter. -If you want to use Etherscan API helpers, you will have to provide Etherscan API key using `ETHERSCAN_KEY` enironmental variable. +If you want to use Etherscan API helpers, you will have to provide Etherscan API +key using `ETHERSCAN_KEY` enironmental variable. -To fail a test if there are any browser console errors, set `FAIL_ON_ERROR` to `1` or `true`. +To fail a test if there are any browser console errors, set `FAIL_ON_ERROR` to +`1` or `true`. -Automatic waiting for XHR requests to finish before tests start can be turned off with `CYPRESS_SKIP_RESOURCES_WAIT` environmental variable, set it to `1` or `true`. +Automatic waiting for XHR requests to finish before tests start can be turned +off with `CYPRESS_SKIP_RESOURCES_WAIT` environmental variable, set it to `1` or +`true`. -If you want to skip metamask extension installation or metamask setup, you can use `SKIP_METAMASK_INSTALL` and `SKIP_METAMASK_SETUP` separately. Both variables accept `1` or `true`. +If you want to skip metamask extension installation or metamask setup, you can +use `SKIP_METAMASK_INSTALL` and `SKIP_METAMASK_SETUP` separately. Both variables +accept `1` or `true`. ## ๐Ÿงช Usage - `synpress run` to run tests -- `synpress open` to open Cypress UI (may be bugged in some cases because it doesn't clear metamask state before each e2e test, please use `synpress run`) +- `synpress open` to open Cypress UI (may be bugged in some cases because it + doesn't clear metamask state before each e2e test, please use `synpress run`) Command line interface (`synpress help`): @@ -174,9 +231,12 @@ Options: 1. Create PR from `dev` branch to `master` branch 2. Merge it (new `-beta` version is automatically released) -3. Run GitHub Action workflow named [Release CI](https://github.com/Synthetixio/synpress/actions/workflows/release.yml) with `patch|minor|major` depending on your needs to promote your build. +3. Run GitHub Action workflow named + [Release CI](https://github.com/Synthetixio/synpress/actions/workflows/release.yml) + with `patch|minor|major` depending on your needs to promote your build. -Alternatively, instead of running GitHub Action for release, you can move on with manual release process: +Alternatively, instead of running GitHub Action for release, you can move on +with manual release process: 1. Switch to `master` branch and pull latest changes 2. Run `npm run release:patch/minor/major` command diff --git a/fixtures/example.json b/fixtures/example.json index da18d9352..02e425437 100644 --- a/fixtures/example.json +++ b/fixtures/example.json @@ -2,4 +2,4 @@ "name": "Using fixtures to represent data", "email": "hello@cypress.io", "body": "Fixtures are a great way to mock data for responses to routes" -} \ No newline at end of file +} diff --git a/support/index.d.ts b/support/index.d.ts index b3d199f8c..f29e4cb3d 100644 --- a/support/index.d.ts +++ b/support/index.d.ts @@ -1,3 +1,4 @@ +// trunk-ignore(eslint) declare namespace Cypress { interface Chainable { /** @@ -193,7 +194,9 @@ declare namespace Cypress { * cy.confirmMetamaskTransaction() * cy.confirmMetamaskTransaction({gasFee: 10, gasLimit: 1000000}) */ - confirmMetamaskTransaction(gasConfig : object | undefined): Chainable; + confirmMetamaskTransaction( + gasConfig: object | undefined, + ): Chainable; /** * Reject metamask transaction * @example From ffa37c86245d41f30528e1b5c9c0d5dc8d25bfa8 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:19:19 +0200 Subject: [PATCH 06/22] chore: accept path for lint sarif report Signed-off-by: Jakub Mucha --- lint.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lint.js b/lint.js index 149552525..459795ec7 100644 --- a/lint.js +++ b/lint.js @@ -28,18 +28,15 @@ const otherFormatter = cli.getFormatter( console.log('Saving sarif report..'); -fs.writeFile( - 'lint-results.sarif', - otherFormatter(report.results), - 'utf8', - () => { - console.log('Sarif report saved'); - if (report.errorCount > 0) { - console.log('Errors found, exiting..'); - process.exit(1); - } else { - console.log('No errors found'); - process.exit(0); - } - }, -); +const filePath = argv[4] ? argv[4] : 'lint-results.sarif'; + +fs.writeFile(filePath, otherFormatter(report.results), 'utf8', () => { + console.log('Sarif report saved'); + if (report.errorCount > 0) { + console.log('Errors found, exiting..'); + process.exit(1); + } else { + console.log('No errors found'); + process.exit(0); + } +}); From c1dc1c3ba3cca0696919b9c80c74ca7d8f07ee64 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:21:13 +0200 Subject: [PATCH 07/22] ci: add trunk Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 342ecf275..2bb419d18 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -5,6 +5,10 @@ on: pull_request: branches: [master, dev] +concurrency: + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: audit: # run only on master/dev branch and pull requests @@ -72,13 +76,18 @@ jobs: run: npm install --legacy-peer-deps --prefer-offline --no-audit - name: Lint + # run only on pull requests + if: github.event_name == 'pull_request' + uses: trunk-io/trunk-action@b64e8d2c91b6bff32cad2c4445656afd942a124d # pin@v1 + + - name: Prepare sarif report # run only on master/dev branch and pull requests if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' run: npm run lint:sarif - - name: Upload lint results + - name: Upload sarif report # run if lint failed and only on master/dev branch and pull requests if: always() && (github.ref == 'refs/heads/master' || github.ref == From 98ecabc97b0006da0e58235ac05ac29be452b1ca Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:25:48 +0200 Subject: [PATCH 08/22] chore: naming changes Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 2bb419d18..6cda5d9e0 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -76,18 +76,13 @@ jobs: run: npm install --legacy-peer-deps --prefer-offline --no-audit - name: Lint - # run only on pull requests - if: github.event_name == 'pull_request' - uses: trunk-io/trunk-action@b64e8d2c91b6bff32cad2c4445656afd942a124d # pin@v1 - - - name: Prepare sarif report # run only on master/dev branch and pull requests if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' run: npm run lint:sarif - - name: Upload sarif report + - name: Upload lint results # run if lint failed and only on master/dev branch and pull requests if: always() && (github.ref == 'refs/heads/master' || github.ref == From 35b9839bd02015d04b05a462bfa592f28eb96209 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:27:02 +0200 Subject: [PATCH 09/22] ci: enable e2e Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 125 ++++++++++++++------------- 1 file changed, 66 insertions(+), 59 deletions(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 6cda5d9e0..db40a40d2 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -92,62 +92,69 @@ jobs: sarif_file: lint-results.sarif continue-on-error: true - # e2e: - # needs: build - # # run only on master/dev branch - # if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' - # runs-on: ubuntu-latest - - # container: - # image: ghcr.io/synthetixio/docker-e2e/ubuntu:16.14 - # credentials: - # username: synthetixio - # password: ${{ secrets.GH_PACKAGES_READ_ONLY }} - - # steps: - # - name: Checkout - # uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 # pin@v2 - - # - name: Set npm cache directory - # run: npm config set cache .npm-cache --global - # continue-on-error: true - - # - name: Cache node modules - # uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v2 - # with: - # path: | - # .npm-cache - # node_modules - # key: ${{ runner.os }}-ubuntu-e2e-16-${{ hashFiles('**/package-lock.json') }} - # restore-keys: | - # ${{ runner.os }}-ubuntu-e2e-16- - # continue-on-error: true - - # # fix: permission issues on ghactions+docker+npm@7 - # - name: Chown workspace - # run: chown -R $(whoami) . - - # - name: Install dependencies - # run: npm install --legacy-peer-deps --prefer-offline --no-audit - # env: - # CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/node_modules/.cache/Cypress - - # - name: Run e2e tests - # run: npm run test:e2e:ci - # env: - # SKIP_METAMASK_SETUP: ${{ secrets.SKIP_METAMASK_SETUP }} - # CYPRESS_PRIVATE_KEY_WITH_FUNDS: ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }} - # CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} - # CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/node_modules/.cache/Cypress - - # - name: Archive e2e artifacts - # uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 # pin@v2 - # if: always() - # with: - # name: e2e-artifacts - # path: | - # tests/e2e/videos - # tests/e2e/screenshots - # continue-on-error: true + e2e: + needs: build + # run only on master/dev branch + if: + github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || + github.event_name == 'pull_request' + runs-on: ubuntu-latest + + container: + image: ghcr.io/synthetixio/docker-e2e/ubuntu:16.14 + credentials: + username: synthetixio + password: ${{ secrets.GH_PACKAGES_READ_ONLY }} + + steps: + - name: Checkout + uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 # pin@v2 + + - name: Set npm cache directory + run: npm config set cache .npm-cache --global + continue-on-error: true + + - name: Cache node modules + uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v2 + with: + path: | + .npm-cache + node_modules + key: + ${{ runner.os }}-ubuntu-e2e-16-${{ hashFiles('**/package-lock.json') + }} + restore-keys: | + ${{ runner.os }}-ubuntu-e2e-16- + continue-on-error: true + + # fix: permission issues on ghactions+docker+npm@7 + - name: Chown workspace + run: chown -R $(whoami) . + + - name: Install dependencies + run: npm install --legacy-peer-deps --prefer-offline --no-audit + env: + CYPRESS_CACHE_FOLDER: + ${{ github.workspace }}/node_modules/.cache/Cypress + + - name: Run e2e tests + run: npm run test:e2e:ci + env: + SKIP_METAMASK_SETUP: ${{ secrets.SKIP_METAMASK_SETUP }} + CYPRESS_PRIVATE_KEY_WITH_FUNDS: + ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }} + CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CYPRESS_CACHE_FOLDER: + ${{ github.workspace }}/node_modules/.cache/Cypress + + - name: Archive e2e artifacts + uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 # pin@v2 + if: always() + with: + name: e2e-artifacts + path: | + tests/e2e/videos + tests/e2e/screenshots + continue-on-error: true From 6e82e7f320ddddb1fcf61226f1675089c4db5e0a Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:34:51 +0200 Subject: [PATCH 10/22] ci: enable trunk Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index db40a40d2..19c77c3bd 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -76,6 +76,13 @@ jobs: run: npm install --legacy-peer-deps --prefer-offline --no-audit - name: Lint + # run only on pull requests + if: + github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || + github.event_name == 'pull_request' + uses: trunk-io/trunk-action@b64e8d2c91b6bff32cad2c4445656afd942a124d # pin@v1 + + - name: Generate sarif report # run only on master/dev branch and pull requests if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || From b358444d337908d3eb11358ea371967530d68337 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:42:14 +0200 Subject: [PATCH 11/22] ci: cleanup Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 132 ++++++++++++--------------- 1 file changed, 59 insertions(+), 73 deletions(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 19c77c3bd..6cda5d9e0 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -76,13 +76,6 @@ jobs: run: npm install --legacy-peer-deps --prefer-offline --no-audit - name: Lint - # run only on pull requests - if: - github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || - github.event_name == 'pull_request' - uses: trunk-io/trunk-action@b64e8d2c91b6bff32cad2c4445656afd942a124d # pin@v1 - - - name: Generate sarif report # run only on master/dev branch and pull requests if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || @@ -99,69 +92,62 @@ jobs: sarif_file: lint-results.sarif continue-on-error: true - e2e: - needs: build - # run only on master/dev branch - if: - github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || - github.event_name == 'pull_request' - runs-on: ubuntu-latest - - container: - image: ghcr.io/synthetixio/docker-e2e/ubuntu:16.14 - credentials: - username: synthetixio - password: ${{ secrets.GH_PACKAGES_READ_ONLY }} - - steps: - - name: Checkout - uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 # pin@v2 - - - name: Set npm cache directory - run: npm config set cache .npm-cache --global - continue-on-error: true - - - name: Cache node modules - uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v2 - with: - path: | - .npm-cache - node_modules - key: - ${{ runner.os }}-ubuntu-e2e-16-${{ hashFiles('**/package-lock.json') - }} - restore-keys: | - ${{ runner.os }}-ubuntu-e2e-16- - continue-on-error: true - - # fix: permission issues on ghactions+docker+npm@7 - - name: Chown workspace - run: chown -R $(whoami) . - - - name: Install dependencies - run: npm install --legacy-peer-deps --prefer-offline --no-audit - env: - CYPRESS_CACHE_FOLDER: - ${{ github.workspace }}/node_modules/.cache/Cypress - - - name: Run e2e tests - run: npm run test:e2e:ci - env: - SKIP_METAMASK_SETUP: ${{ secrets.SKIP_METAMASK_SETUP }} - CYPRESS_PRIVATE_KEY_WITH_FUNDS: - ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }} - CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CYPRESS_CACHE_FOLDER: - ${{ github.workspace }}/node_modules/.cache/Cypress - - - name: Archive e2e artifacts - uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 # pin@v2 - if: always() - with: - name: e2e-artifacts - path: | - tests/e2e/videos - tests/e2e/screenshots - continue-on-error: true + # e2e: + # needs: build + # # run only on master/dev branch + # if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request' + # runs-on: ubuntu-latest + + # container: + # image: ghcr.io/synthetixio/docker-e2e/ubuntu:16.14 + # credentials: + # username: synthetixio + # password: ${{ secrets.GH_PACKAGES_READ_ONLY }} + + # steps: + # - name: Checkout + # uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 # pin@v2 + + # - name: Set npm cache directory + # run: npm config set cache .npm-cache --global + # continue-on-error: true + + # - name: Cache node modules + # uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # pin@v2 + # with: + # path: | + # .npm-cache + # node_modules + # key: ${{ runner.os }}-ubuntu-e2e-16-${{ hashFiles('**/package-lock.json') }} + # restore-keys: | + # ${{ runner.os }}-ubuntu-e2e-16- + # continue-on-error: true + + # # fix: permission issues on ghactions+docker+npm@7 + # - name: Chown workspace + # run: chown -R $(whoami) . + + # - name: Install dependencies + # run: npm install --legacy-peer-deps --prefer-offline --no-audit + # env: + # CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/node_modules/.cache/Cypress + + # - name: Run e2e tests + # run: npm run test:e2e:ci + # env: + # SKIP_METAMASK_SETUP: ${{ secrets.SKIP_METAMASK_SETUP }} + # CYPRESS_PRIVATE_KEY_WITH_FUNDS: ${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }} + # CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} + # CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # CYPRESS_CACHE_FOLDER: ${{ github.workspace }}/node_modules/.cache/Cypress + + # - name: Archive e2e artifacts + # uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074 # pin@v2 + # if: always() + # with: + # name: e2e-artifacts + # path: | + # tests/e2e/videos + # tests/e2e/screenshots + # continue-on-error: true From 6d59fead901432707c5e8c53db96f56a247c0d29 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:55:07 +0200 Subject: [PATCH 12/22] ci: use dockerhub Signed-off-by: Jakub Mucha --- .github/workflows/audit_and_lint.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 6cda5d9e0..49c560741 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -18,10 +18,7 @@ jobs: runs-on: ubuntu-latest container: - image: ghcr.io/synthetixio/docker-sec-tools/alpine:16.14 - credentials: - username: synthetixio - password: ${{ secrets.GH_PACKAGES_READ_ONLY }} + image: synthetixio/docker-sec-tools:16.14-alpine steps: - name: Checkout @@ -45,10 +42,7 @@ jobs: runs-on: ubuntu-latest container: - image: ghcr.io/synthetixio/docker-node/alpine:16.14 - credentials: - username: synthetixio - password: ${{ secrets.GH_PACKAGES_READ_ONLY }} + image: synthetixio/docker-node:16.14-alpine steps: - name: Checkout From 3eb9ba2aa160a500f9f29275058d6a4bccb1a983 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 30 Aug 2022 21:59:45 +0200 Subject: [PATCH 13/22] chore: readme up Signed-off-by: Jakub Mucha --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e01619958..be34a608e 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ mirror and modify it for your needs. Then you can direct synpress to use it with `--configFile` flag. -For example: `synpress run --configFile __tests__/e2e/customConfig.json` +For example: `synpress run --configFile __tests__/e2e/customConfig.config.js` ## โšก Important From b882ac52e2c8749b300fbeb439e3f18cda0642cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 17:03:57 +0000 Subject: [PATCH 14/22] chore(deps): bump github/codeql-action from 2.1.21 to 2.1.22 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.21 to 2.1.22. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/c7f292ea4f542c473194b33813ccd4c207a6c725...b398f525a5587552e573b247ac661067fafa920b) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/audit_and_lint.yml | 2 +- .github/workflows/codeql.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/audit_and_lint.yml b/.github/workflows/audit_and_lint.yml index 49c560741..84d5a2422 100644 --- a/.github/workflows/audit_and_lint.yml +++ b/.github/workflows/audit_and_lint.yml @@ -81,7 +81,7 @@ jobs: if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request') - uses: github/codeql-action/upload-sarif@c7f292ea4f542c473194b33813ccd4c207a6c725 # pin@codeql-bundle-20210517 + uses: github/codeql-action/upload-sarif@b398f525a5587552e573b247ac661067fafa920b # pin@codeql-bundle-20210517 with: sarif_file: lint-results.sarif continue-on-error: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9d2ac0500..ba320e779 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -17,10 +17,10 @@ jobs: uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # pin@v2 - name: Initialize CodeQL - uses: github/codeql-action/init@c7f292ea4f542c473194b33813ccd4c207a6c725 + uses: github/codeql-action/init@b398f525a5587552e573b247ac661067fafa920b with: queries: security-and-quality languages: javascript - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@c7f292ea4f542c473194b33813ccd4c207a6c725 + uses: github/codeql-action/analyze@b398f525a5587552e573b247ac661067fafa920b From 32c0b22903c3ad1d6ab9d0cb64c21f2ea6b73ec3 Mon Sep 17 00:00:00 2001 From: NatalieXSelina <108204536+NatalieXSelina@users.noreply.github.com> Date: Sun, 4 Sep 2022 22:13:25 +0800 Subject: [PATCH 15/22] update: make sure button can be clicked when message content is too long, the button is not visible in the current window, add foucs to make sure the button can be clicked. --- commands/puppeteer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/puppeteer.js b/commands/puppeteer.js index 1efbf7b6e..bdb2f8eb6 100644 --- a/commands/puppeteer.js +++ b/commands/puppeteer.js @@ -105,6 +105,7 @@ module.exports = { }, waitAndClick: async (selector, page = metamaskWindow, numberOfClicks) => { await module.exports.waitFor(selector, page); + await page.focus(selector); if (numberOfClicks) { let i = 0; while (i < numberOfClicks) { From 99f040582cd71e2517c47620ccdd4de7731fd072 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 22:34:27 +0200 Subject: [PATCH 16/22] chore: specify supportFile path Signed-off-by: Jakub Mucha --- synpress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synpress.config.js b/synpress.config.js index bdb834e1e..81c1a2792 100644 --- a/synpress.config.js +++ b/synpress.config.js @@ -3,7 +3,7 @@ const setupNodeEvents = require('./plugins/index'); const helpers = require('./helpers'); const fixturesFolder = `${helpers.getSynpressPath()}/fixtures`; -const supportFile = `${helpers.getSynpressPath()}/support/index.js`; +const supportFile = 'tests/e2e/supportFile.js'; module.exports = defineConfig({ userAgent: 'synpress', From 371a7f59f170928de24cd2c31f3ea5fdee22637b Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 22:41:59 +0200 Subject: [PATCH 17/22] chore: support path change Signed-off-by: Jakub Mucha --- synpress.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synpress.config.js b/synpress.config.js index 81c1a2792..d88c6c0b0 100644 --- a/synpress.config.js +++ b/synpress.config.js @@ -3,7 +3,7 @@ const setupNodeEvents = require('./plugins/index'); const helpers = require('./helpers'); const fixturesFolder = `${helpers.getSynpressPath()}/fixtures`; -const supportFile = 'tests/e2e/supportFile.js'; +const supportFile = 'tests/e2e/support.js'; module.exports = defineConfig({ userAgent: 'synpress', From 4f58c61357a2a3766e2cfb5911c947dd5f13c337 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 22:53:50 +0200 Subject: [PATCH 18/22] chore: readme update Signed-off-by: Jakub Mucha --- README.md | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index be34a608e..cf2e9eea7 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ ran. It also provides an easy way to use metamask straight from your e2e tests. For usage examples, feel free to take a look at -[kwenta](https://github.com/kwenta/kwenta/tree/master/tests/e2e), -[staking](https://github.com/Synthetixio/staking/tree/master/tests/e2e) or -[synpress](https://github.com/Synthetixio/synpress/tree/master/tests/e2e) +[kwenta](https://github.com/kwenta/kwenta/tree/dev/tests/e2e), +[staking](https://github.com/Synthetixio/staking/tree/dev/tests/e2e) or +[synpress](https://github.com/Synthetixio/synpress/tree/dev/tests/e2e) repository. For additional custom commands and their examples, -[check here](https://github.com/synthetixio/synpress/blob/master/support/index.d.ts). +[check here](https://github.com/synthetixio/synpress/blob/dev/support/index.d.ts). To see in which direction Synpress is headed to, take a look at this [planning board](https://github.com/orgs/Synthetixio/projects/14). @@ -63,6 +63,7 @@ project_dir โ””โ”€โ”€ tests โ””โ”€โ”€ e2e โ””โ”€โ”€ .eslintrc.js + โ””โ”€โ”€ support.js โ””โ”€โ”€ tsconfig.json โ””โ”€โ”€ specs โ””โ”€โ”€ example-spec.js @@ -84,7 +85,14 @@ module.exports = { }; ``` -2. Create `tsconfig.json` inside your tests folder (`/project_dir/tests/e2e`): +2. Create `support.js` inside your tests folder (`/project_dir/tests/e2e`): + +```js +import '@synthetixio/synpress/support/index'; +``` +*hint: you can also use this file to extend synpress, add custom commands, and more..* + +3. Create `tsconfig.json` inside your tests folder (`/project_dir/tests/e2e`): ```json { @@ -104,11 +112,14 @@ module.exports = { } ``` -3. You're done! ๐ŸŽ‰ +4. You're done! ๐ŸŽ‰ + +To change specific values in default config, you can use `--config` flag. +For example, to change path for `support.js` file, you can use `synpress run --config "supportFile=__tests__/e2e/supportFile.js"` If you would like to use custom paths for your tests and configs, feel free to mirror -[default synpress config](https://github.com/Synthetixio/synpress/blob/dev/synpress.json) +[default synpress config](https://github.com/Synthetixio/synpress/blob/dev/synpress.config.js) and modify it for your needs. Then you can direct synpress to use it with `--configFile` flag. @@ -126,7 +137,7 @@ mode in [puppeteer](https://github.com/puppeteer/puppeteer/issues/659) and It's intended to be used in conjunction with `xvfb` on CI. There is a global -[`before()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L25) +[`before()`](https://github.com/synthetixio/synpress/blob/dev/support/index.js#L27) which runs metamask setup before all tests: - passes welcome page @@ -161,7 +172,7 @@ override metamask with `METAMASK_VERSION` environmental variable, for example: `METAMASK_VERSION=9.3.0` or `METAMASK_VERSION=latest`. If you don't want to use environmental variables, you can modify -[`setupMetamask()`](https://github.com/synthetixio/synpress/blob/master/support/index.js#L26) +[`setupMetamask()`](https://github.com/synthetixio/synpress/blob/dev/support/index.js#L29) to following: `setupMetamask(secretWordsOrPrivateKey, network, password)`, for example: @@ -201,7 +212,7 @@ launch tests Options: -b, --browser run on specified browser (default: "chrome") -c, --config set configuration values, separate multiple values with a comma - -cf, --configFile specify a path to a JSON file where configuration values are set + -cf, --configFile specify a path to *.js file where configuration values are set -e, --env set environment variables, separate multiple values with comma -s, --spec run only provided spec files -ne, --noExit keep runner open after tests finish @@ -223,7 +234,7 @@ Usage: synpress open [options] launch test runner UI Options: - -cf, --configFile specify a path to a JSON file where configuration values are set + -cf, --configFile specify a path to *.js file where configuration values are set -h, --help display help for command ``` From 1dfbec9b064fe6a44b13eb02c2340d07a1f1f894 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 22:55:15 +0200 Subject: [PATCH 19/22] BREAKING: support.js file is now required Signed-off-by: Jakub Mucha From b7dfb1acf32f6c5fe505e5b7665a6a11308d53b3 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 23:00:38 +0200 Subject: [PATCH 20/22] chore: readme up Signed-off-by: Jakub Mucha --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf2e9eea7..4439b3a26 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ module.exports = { ```js import '@synthetixio/synpress/support/index'; ``` -*hint: you can also use this file to extend synpress, add custom commands, and more..* +*hint: you can also use this file to extend synpress - add custom commands, and more..* 3. Create `tsconfig.json` inside your tests folder (`/project_dir/tests/e2e`): @@ -258,3 +258,8 @@ Above actions will lead to: - New npm node module release - New GitHub packages node module release - New GitHub release (tagged) created with changelog from commit messages + +## ๐Ÿ“ƒ More resources +- https://medium.com/andamp/how-to-setup-synpress-for-wen3-dapp-frontend-test-automation-with-metamask-73396896684a +- https://medium.com/andamp/extending-synpress-with-additional-metamask-commands-fdc6b35a2ffc +- https://medium.com/coinmonks/test-e2e-login-to-dapp-with-metamask-with-synpress-5248dd1f17c1 From c584d9e888dfe65cfa2fce5c892b8cd5eef4eac7 Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 23:01:30 +0200 Subject: [PATCH 21/22] readme: up Signed-off-by: Jakub Mucha --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4439b3a26..db84e8ad5 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ module.exports = { ```js import '@synthetixio/synpress/support/index'; ``` -*hint: you can also use this file to extend synpress - add custom commands, and more..* +*^ hint: you can also use this file to extend synpress - add custom commands, and more..* 3. Create `tsconfig.json` inside your tests folder (`/project_dir/tests/e2e`): From 32334ef358cc8caca3f4ae2e0da17e43092697be Mon Sep 17 00:00:00 2001 From: Jakub Mucha Date: Tue, 6 Sep 2022 23:02:30 +0200 Subject: [PATCH 22/22] fix: lint Signed-off-by: Jakub Mucha --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db84e8ad5..d517d5bf1 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,9 @@ module.exports = { ```js import '@synthetixio/synpress/support/index'; ``` -*^ hint: you can also use this file to extend synpress - add custom commands, and more..* + +_^ hint: you can also use this file to extend synpress - add custom commands, +and more.._ 3. Create `tsconfig.json` inside your tests folder (`/project_dir/tests/e2e`): @@ -114,8 +116,9 @@ import '@synthetixio/synpress/support/index'; 4. You're done! ๐ŸŽ‰ -To change specific values in default config, you can use `--config` flag. -For example, to change path for `support.js` file, you can use `synpress run --config "supportFile=__tests__/e2e/supportFile.js"` +To change specific values in default config, you can use `--config` flag. For +example, to change path for `support.js` file, you can use +`synpress run --config "supportFile=__tests__/e2e/supportFile.js"` If you would like to use custom paths for your tests and configs, feel free to mirror @@ -260,6 +263,7 @@ Above actions will lead to: - New GitHub release (tagged) created with changelog from commit messages ## ๐Ÿ“ƒ More resources + - https://medium.com/andamp/how-to-setup-synpress-for-wen3-dapp-frontend-test-automation-with-metamask-73396896684a - https://medium.com/andamp/extending-synpress-with-additional-metamask-commands-fdc6b35a2ffc - https://medium.com/coinmonks/test-e2e-login-to-dapp-with-metamask-with-synpress-5248dd1f17c1