├── .babelrc ├── .circleci └── config.yml ├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .github └── assets │ ├── install-button.png │ └── knapsack.png ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bin └── setup_development ├── gulpfile.babel.js ├── package-lock.json ├── package.json ├── src ├── cypress-cli.ts ├── env-config.ts ├── knapsack-pro-cypress.ts ├── test-files-finder.ts └── urls.ts └── tsconfig.json /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "node": "current" 8 | } 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Javascript Node.js CircleCI 2.0 configuration file 2 | # https://circleci.com/docs/2.0/language-javascript/ 3 | 4 | version: 2 5 | jobs: 6 | build: 7 | docker: 8 | - image: cimg/node:16.15 9 | 10 | working_directory: ~/knapsack-pro-cypress 11 | 12 | steps: 13 | # clone @knapsack-pro/core project 14 | - run: 15 | name: Checkout code of @knapsack-pro/core 16 | command: cd ~ && (git clone -b $CIRCLE_BRANCH --single-branch https://github.com/KnapsackPro/knapsack-pro-core-js.git || git clone --single-branch https://github.com/KnapsackPro/knapsack-pro-core-js.git) 17 | 18 | # set up @knapsack-pro/core project 19 | - restore_cache: 20 | name: Restoring Cache of @knapsack-pro/core 21 | keys: 22 | - v1-knapsack-pro-core-{{ checksum "~/knapsack-pro-core-js/package.json" }} 23 | # fallback to the latest cache if no exact match is found 24 | - v1-knapsack-pro-core- 25 | 26 | - run: cd ~/knapsack-pro-core-js && npm install 27 | - run: cd ~/knapsack-pro-core-js && npm run build 28 | - run: cd ~/knapsack-pro-core-js && npm link 29 | 30 | - save_cache: 31 | name: Saving Cache of @knapsack-pro/core 32 | key: v1-knapsack-pro-core-{{ checksum "~/knapsack-pro-core-js/package.json" }} 33 | paths: 34 | - ~/knapsack-pro-core-js/node_modules 35 | 36 | # check out source code to working directory 37 | - checkout 38 | 39 | # restore, install and cache dependencies 40 | - restore_cache: 41 | keys: 42 | - v1-dependencies-{{ checksum "package.json" }} 43 | # fallback to the latest cache if no exact match is found 44 | - v1-dependencies- 45 | - run: npm install 46 | - run: npm link @knapsack-pro/core 47 | - save_cache: 48 | key: v1-dependencies-{{ checksum "package.json" }} 49 | paths: 50 | - node_modules 51 | 52 | # build project 53 | - run: npm run build 54 | 55 | # run code linters 56 | - run: 57 | name: ESLint check 58 | command: npm run eslint:check 59 | - run: 60 | name: Prettier check 61 | command: npm run prettier:check 62 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /lib 3 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint", "prettier"], 5 | "extends": [ 6 | "eslint:recommended", 7 | "plugin:@typescript-eslint/eslint-recommended", 8 | "plugin:@typescript-eslint/recommended", 9 | "airbnb-base", 10 | "prettier" 11 | ], 12 | "rules": { 13 | "prettier/prettier": "error", 14 | "no-unused-vars": "warn", 15 | "no-console": "off", 16 | "func-names": "off", 17 | "no-process-exit": "off", 18 | "object-shorthand": "off", 19 | "class-methods-use-this": "off", 20 | "comma-dangle": ["error"], 21 | "import/prefer-default-export": "off", 22 | "import/no-unresolved": "off", 23 | "import/extensions": "off" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/assets/install-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnapsackPro/knapsack-pro-cypress/dbf435df4baf60a7b3122d483022aeac7cdc33be/.github/assets/install-button.png -------------------------------------------------------------------------------- /.github/assets/knapsack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KnapsackPro/knapsack-pro-cypress/dbf435df4baf60a7b3122d483022aeac7cdc33be/.github/assets/knapsack.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /.env 3 | 4 | # compiled ts files to js 5 | /lib 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts: 2 | /coverage 3 | 4 | # lib contains compiled typescript to js code 5 | /lib 6 | 7 | # changelog is generated by github_changelog_generator gem 8 | CHANGELOG.md 9 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "trailingComma": "all", 4 | "singleQuote": true 5 | } 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [v6.1.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v6.1.0) (2023-05-23) 4 | 5 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v6.0.0...v6.1.0) 6 | 7 | **Merged pull requests:** 8 | 9 | - Update @knapsack-pro/core to 5.1.0 [\#95](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/95) ([ArturT](https://github.com/ArturT)) 10 | 11 | ## [v6.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v6.0.0) (2023-05-22) 12 | 13 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.6.0...v6.0.0) 14 | 15 | **Merged pull requests:** 16 | 17 | - Update @knapsack-pro/core to 5.0.0 [\#94](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/94) ([3v0k4](https://github.com/3v0k4)) 18 | 19 | ## [v5.6.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.6.0) (2023-05-04) 20 | 21 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.5.0...v5.6.0) 22 | 23 | **Merged pull requests:** 24 | 25 | - Update @knapsack-pro/core to 4.1.0 [\#93](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/93) ([ArturT](https://github.com/ArturT)) 26 | 27 | ## [v5.5.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.5.0) (2023-03-01) 28 | 29 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.4.0...v5.5.0) 30 | 31 | **Closed issues:** 32 | 33 | - Update for Cypress 12 [\#89](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/89) 34 | 35 | **Merged pull requests:** 36 | 37 | - Permalinks [\#92](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/92) ([3v0k4](https://github.com/3v0k4)) 38 | 39 | ## [v5.4.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.4.0) (2023-02-22) 40 | 41 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.3.1...v5.4.0) 42 | 43 | **Merged pull requests:** 44 | 45 | - Update peerDependencies and update Cypress version [\#91](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/91) ([ArturT](https://github.com/ArturT)) 46 | - Tweak readme [\#90](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/90) ([3v0k4](https://github.com/3v0k4)) 47 | 48 | ## [v5.3.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.3.1) (2023-01-31) 49 | 50 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.3.0...v5.3.1) 51 | 52 | **Fixed bugs:** 53 | 54 | - Search for test files on the disk only if needed by the `@knapsack-pro/core` [\#88](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/88) ([ArturT](https://github.com/ArturT)) 55 | 56 | ## [v5.3.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.3.0) (2023-01-30) 57 | 58 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.2.0...v5.3.0) 59 | 60 | **Implemented enhancements:** 61 | 62 | - Update @knapsack-pro/core to 3.3.1 [\#87](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/87) ([ArturT](https://github.com/ArturT)) 63 | 64 | **Merged pull requests:** 65 | 66 | - Bump json5 from 1.0.1 to 1.0.2 [\#83](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/83) ([dependabot[bot]](https://github.com/apps/dependabot)) 67 | - Bump decode-uri-component from 0.2.0 to 0.2.2 [\#81](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/81) ([dependabot[bot]](https://github.com/apps/dependabot)) 68 | 69 | ## [v5.2.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.2.0) (2023-01-16) 70 | 71 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.1.0...v5.2.0) 72 | 73 | **Implemented enhancements:** 74 | 75 | - Feature: Support exclusion pattern with KNAPSACK\_PRO\_TEST\_FILE\_EXCLUDE\_PATTERN env var [\#84](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/84) 76 | - Support env KNAPSACK\_PRO\_TEST\_FILE\_EXCLUDE\_PATTERN [\#85](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/85) ([renehernandez](https://github.com/renehernandez)) 77 | 78 | **Fixed bugs:** 79 | 80 | - Improvements: make project compile again [\#86](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/86) ([ArturT](https://github.com/ArturT)) 81 | 82 | **Merged pull requests:** 83 | 84 | - Point installation to docs on knapsackspro.com [\#82](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/82) ([3v0k4](https://github.com/3v0k4)) 85 | 86 | ## [v5.1.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.1.0) (2022-06-17) 87 | 88 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v5.0.0...v5.1.0) 89 | 90 | **Implemented enhancements:** 91 | 92 | - Remove tracking legacy wallClockDuration for Cypress 3.x and 4.x [\#78](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/78) ([ArturT](https://github.com/ArturT)) 93 | 94 | **Fixed bugs:** 95 | 96 | - Catch an exception from cypress.run to handle UnhandledPromiseRejectionWarning [\#79](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/79) ([ArturT](https://github.com/ArturT)) 97 | 98 | ## [v5.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v5.0.0) (2022-06-13) 99 | 100 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.6.0...v5.0.0) 101 | 102 | **Closed issues:** 103 | 104 | - \[Security\] Upgrade axios dependency in `@knapsack-pro/core` to 0.21.2 or later [\#70](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/70) 105 | 106 | **Merged pull requests:** 107 | 108 | - \[breaking change\] Add support for Cypress 10.x [\#77](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/77) ([ArturT](https://github.com/ArturT)) 109 | 110 | ## [v4.6.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.6.0) (2022-06-13) 111 | 112 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.5.0...v4.6.0) 113 | 114 | **Merged pull requests:** 115 | 116 | - Update dependencies and development ESLint config [\#75](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/75) ([ArturT](https://github.com/ArturT)) 117 | - Fix the link to test file pattern examples in README [\#74](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/74) ([ArturT](https://github.com/ArturT)) 118 | - Add component testing instructions to readme [\#69](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/69) ([mattvague](https://github.com/mattvague)) 119 | 120 | ## [v4.5.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.5.0) (2021-11-17) 121 | 122 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.4.1...v4.5.0) 123 | 124 | **Implemented enhancements:** 125 | 126 | - Can't force disable Cypress recording [\#66](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/66) 127 | 128 | **Merged pull requests:** 129 | 130 | - Allow Cypress 9.x as peer dependency [\#68](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/68) ([ArturT](https://github.com/ArturT)) 131 | 132 | ## [v4.4.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.4.1) (2021-08-19) 133 | 134 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.4.0...v4.4.1) 135 | 136 | **Implemented enhancements:** 137 | 138 | - Allow user to disable recording with `--record false` flag [\#67](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/67) ([ArturT](https://github.com/ArturT)) 139 | 140 | ## [v4.4.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.4.0) (2021-08-11) 141 | 142 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.3.1...v4.4.0) 143 | 144 | **Closed issues:** 145 | 146 | - Bitbucket Guideline - Issues to know exactly how I have to install this by using bitbucket [\#56](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/56) 147 | - Rerunning pipelines may not work with --project flag. [\#53](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/53) 148 | 149 | **Merged pull requests:** 150 | 151 | - Bump path-parse from 1.0.5 to 1.0.7 [\#65](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/65) ([dependabot[bot]](https://github.com/apps/dependabot)) 152 | - Allow Cypress 8.x as peer dependency [\#64](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/64) ([ArturT](https://github.com/ArturT)) 153 | - npm audit fix [\#63](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/63) ([ArturT](https://github.com/ArturT)) 154 | - Bump color-string from 1.5.4 to 1.6.0 [\#62](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/62) ([dependabot[bot]](https://github.com/apps/dependabot)) 155 | - Bump browserslist from 4.14.0 to 4.16.6 [\#61](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/61) ([dependabot[bot]](https://github.com/apps/dependabot)) 156 | - Bump hosted-git-info from 2.5.0 to 2.8.9 [\#60](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/60) ([dependabot[bot]](https://github.com/apps/dependabot)) 157 | - Bump lodash from 4.17.20 to 4.17.21 [\#59](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/59) ([dependabot[bot]](https://github.com/apps/dependabot)) 158 | 159 | ## [v4.3.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.3.1) (2021-04-14) 160 | 161 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.3.0...v4.3.1) 162 | 163 | **Merged pull requests:** 164 | 165 | - Remove FAQ questions from readme and update link to FAQ in an error message [\#58](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/58) ([ArturT](https://github.com/ArturT)) 166 | - Add BitBucket Pipeline info to readme [\#57](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/57) ([ArturT](https://github.com/ArturT)) 167 | 168 | ## [v4.3.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.3.0) (2021-04-09) 169 | 170 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.2.1...v4.3.0) 171 | 172 | **Merged pull requests:** 173 | 174 | - Allow Cypress 7.x as peer dependency [\#55](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/55) ([ArturT](https://github.com/ArturT)) 175 | - Bump y18n from 3.2.1 to 3.2.2 [\#54](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/54) ([dependabot[bot]](https://github.com/apps/dependabot)) 176 | 177 | ## [v4.2.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.2.1) (2021-01-07) 178 | 179 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.2.0...v4.2.1) 180 | 181 | **Merged pull requests:** 182 | 183 | - Update @knapsack-pro/core to 3.1.1 [\#52](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/52) ([ArturT](https://github.com/ArturT)) 184 | - Bump ini from 1.3.5 to 1.3.8 [\#51](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/51) ([dependabot[bot]](https://github.com/apps/dependabot)) 185 | 186 | ## [v4.2.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.2.0) (2020-11-28) 187 | 188 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.1.0...v4.2.0) 189 | 190 | **Implemented enhancements:** 191 | 192 | - Update @knapsack-pro/core 3.1.0 - Add support for an attempt to connect to existing Queue on API side to reduce slow requests number [\#49](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/49) ([ArturT](https://github.com/ArturT)) 193 | 194 | ## [v4.1.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.1.0) (2020-11-28) 195 | 196 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.0.2...v4.1.0) 197 | 198 | **Merged pull requests:** 199 | 200 | - Update cypress peerDependencies to allow Cypress 6.x version [\#48](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/48) ([ArturT](https://github.com/ArturT)) 201 | 202 | ## [v4.0.2](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.0.2) (2020-11-12) 203 | 204 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.0.1...v4.0.2) 205 | 206 | **Fixed bugs:** 207 | 208 | - When you use --record flag to send data to Cypress Dashboard then generate a unique group name for each set of tests fetched from Knapsack Pro Queue API to make Cypress Dashboard accept recorded data. [\#47](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/47) ([ArturT](https://github.com/ArturT)) 209 | 210 | **Closed issues:** 211 | 212 | - Missing build id environment variable for github actions [\#45](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/45) 213 | - False positive \(zero exit code\) returned when versions mismatch [\#43](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/43) 214 | 215 | **Merged pull requests:** 216 | 217 | - Add Github Actions build ID to FAQ [\#46](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/46) ([ArturT](https://github.com/ArturT)) 218 | 219 | ## [v4.0.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.0.1) (2020-09-18) 220 | 221 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.0.0...v4.0.1) 222 | 223 | **Merged pull requests:** 224 | 225 | - Update @knapsack-pro/core 3.0.1 [\#42](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/42) ([ArturT](https://github.com/ArturT)) 226 | - Bump lodash from 4.17.15 to 4.17.20 [\#41](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/41) ([dependabot[bot]](https://github.com/apps/dependabot)) 227 | 228 | ## [v4.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.0.0) (2020-08-26) 229 | 230 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v4.0.0-beta.0...v4.0.0) 231 | 232 | ## [v4.0.0-beta.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v4.0.0-beta.0) (2020-08-26) 233 | 234 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v3.1.0...v4.0.0-beta.0) 235 | 236 | **Implemented enhancements:** 237 | 238 | - Add cypress \>=3.0.0 \<6.0.0 to peerDependencies [\#40](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/40) ([ArturT](https://github.com/ArturT)) 239 | - Add support to read test duration time for Cypress 5.x [\#39](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/39) ([ArturT](https://github.com/ArturT)) 240 | - Use @knapsack-pro/core 3.0.0 [\#36](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/36) ([ArturT](https://github.com/ArturT)) 241 | 242 | **Closed issues:** 243 | 244 | - Update cypress dependency [\#32](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/32) 245 | 246 | **Merged pull requests:** 247 | 248 | - Update packages [\#38](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/38) ([ArturT](https://github.com/ArturT)) 249 | - Update formatting related configs \(prettier etc\) [\#37](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/37) ([ArturT](https://github.com/ArturT)) 250 | - Use Node 12.18.3 LTS in development and update README requirements [\#35](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/35) ([ArturT](https://github.com/ArturT)) 251 | 252 | ## [v3.1.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v3.1.0) (2020-07-30) 253 | 254 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v3.0.0...v3.1.0) 255 | 256 | **Merged pull requests:** 257 | 258 | - Update cypress dependency to \>= 4.9.0 [\#33](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/33) ([ArturT](https://github.com/ArturT)) 259 | 260 | ## [v3.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v3.0.0) (2020-06-27) 261 | 262 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v2.0.0...v3.0.0) 263 | 264 | **Implemented enhancements:** 265 | 266 | - \[breaking change\] Update to @knapsack-pro/core 2.0.0 - read PR description how to migrate for Github Actions [\#31](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/31) ([ArturT](https://github.com/ArturT)) 267 | 268 | **Merged pull requests:** 269 | 270 | - Bump lodash from 4.17.11 to 4.17.15 [\#30](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/30) ([dependabot[bot]](https://github.com/apps/dependabot)) 271 | - Bump minimist from 1.2.0 to 1.2.3 [\#28](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/28) ([dependabot[bot]](https://github.com/apps/dependabot)) 272 | 273 | ## [v2.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v2.0.0) (2020-02-20) 274 | 275 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.7.0...v2.0.0) 276 | 277 | **Merged pull requests:** 278 | 279 | - Update dependency to use Cypress 4.x [\#26](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/26) ([ArturT](https://github.com/ArturT)) 280 | 281 | ## [v1.7.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.7.0) (2019-11-22) 282 | 283 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.6.0...v1.7.0) 284 | 285 | **Implemented enhancements:** 286 | 287 | - Run tests only when they are detected on the disk. Do not run tests when the test file pattern is invalid. Require to set KNAPSACK\_PRO\_TEST\_FILE\_PATTERN [\#21](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/21) ([ArturT](https://github.com/ArturT)) 288 | 289 | **Merged pull requests:** 290 | 291 | - Bump lodash.merge from 4.6.1 to 4.6.2 [\#25](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/25) ([dependabot[bot]](https://github.com/apps/dependabot)) 292 | - Bump eslint-utils from 1.3.1 to 1.4.3 [\#24](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/24) ([dependabot[bot]](https://github.com/apps/dependabot)) 293 | - Bump mixin-deep from 1.3.1 to 1.3.2 [\#23](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/23) ([dependabot[bot]](https://github.com/apps/dependabot)) 294 | - Bump extend from 3.0.1 to 3.0.2 [\#22](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/22) ([dependabot[bot]](https://github.com/apps/dependabot)) 295 | 296 | ## [v1.6.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.6.0) (2019-10-13) 297 | 298 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.5.1...v1.6.0) 299 | 300 | **Implemented enhancements:** 301 | 302 | - Add support for Codefresh.io CI provider [\#19](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/19) ([ArturT](https://github.com/ArturT)) 303 | 304 | ## [v1.5.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.5.1) (2019-09-26) 305 | 306 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.5.0...v1.5.1) 307 | 308 | **Fixed bugs:** 309 | 310 | - fix\(bug\): When Cypress crashed then exit code should be 1 [\#18](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/18) ([ArturT](https://github.com/ArturT)) 311 | 312 | ## [v1.5.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.5.0) (2019-09-15) 313 | 314 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.4.1...v1.5.0) 315 | 316 | **Implemented enhancements:** 317 | 318 | - Update @knapsack-pro/core 1.5.0 to add support for GitHub Actions [\#17](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/17) ([ArturT](https://github.com/ArturT)) 319 | 320 | ## [v1.4.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.4.1) (2019-09-04) 321 | 322 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.4.0...v1.4.1) 323 | 324 | **Fixed bugs:** 325 | 326 | - Update @knapsack-pro/core 1.4.1 [\#16](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/16) ([ArturT](https://github.com/ArturT)) 327 | 328 | ## [v1.4.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.4.0) (2019-08-23) 329 | 330 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.3.1...v1.4.0) 331 | 332 | **Implemented enhancements:** 333 | 334 | - Update @knapsack-pro/core 1.4.0 and update docs for Semaphore 2.0 [\#15](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/15) ([ArturT](https://github.com/ArturT)) 335 | 336 | ## [v1.3.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.3.1) (2019-07-06) 337 | 338 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.3.0...v1.3.1) 339 | 340 | **Fixed bugs:** 341 | 342 | - Update @knapsack-pro/core 1.3.1 [\#14](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/14) ([ArturT](https://github.com/ArturT)) 343 | 344 | ## [v1.3.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.3.0) (2019-04-14) 345 | 346 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.2.0...v1.3.0) 347 | 348 | **Implemented enhancements:** 349 | 350 | - Reduce data transfer and speed up usage of Knapsack Pro API for Queue Mode [\#13](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/13) ([ArturT](https://github.com/ArturT)) 351 | 352 | ## [v1.2.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.2.0) (2019-03-15) 353 | 354 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.1.0...v1.2.0) 355 | 356 | **Implemented enhancements:** 357 | 358 | - Pass CLI arguments to cypress.run [\#10](https://github.com/KnapsackPro/knapsack-pro-cypress/issues/10) 359 | - Add support for Semaphore CI 2.0 [\#12](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/12) ([ArturT](https://github.com/ArturT)) 360 | 361 | ## [v1.1.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.1.0) (2019-03-07) 362 | 363 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.0.1...v1.1.0) 364 | 365 | **Implemented enhancements:** 366 | 367 | - Add support for Cypress CLI arguments and update Cypress to ^3.1.5 [\#11](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/11) ([ArturT](https://github.com/ArturT)) 368 | 369 | **Merged pull requests:** 370 | 371 | - Update package dependencies [\#9](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/9) ([rafaltrzop](https://github.com/rafaltrzop)) 372 | 373 | ## [v1.0.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.0.1) (2018-12-29) 374 | 375 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v1.0.0...v1.0.1) 376 | 377 | ## [v1.0.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v1.0.0) (2018-12-29) 378 | 379 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.3.1...v1.0.0) 380 | 381 | **Implemented enhancements:** 382 | 383 | - Add changes related to fallback mode [\#8](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/8) ([ArturT](https://github.com/ArturT)) 384 | 385 | **Merged pull requests:** 386 | 387 | - Add ESLint with Airbnb base config [\#7](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/7) ([ArturT](https://github.com/ArturT)) 388 | - Add Prettier and configure TSLint [\#6](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/6) ([ArturT](https://github.com/ArturT)) 389 | 390 | ## [v0.3.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.3.1) (2018-11-15) 391 | 392 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.3.0...v0.3.1) 393 | 394 | ## [v0.3.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.3.0) (2018-11-15) 395 | 396 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.2.1...v0.3.0) 397 | 398 | **Implemented enhancements:** 399 | 400 | - Add support for GitLab \>= 11.5 env variables [\#5](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/5) ([ArturT](https://github.com/ArturT)) 401 | 402 | ## [v0.2.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.2.1) (2018-10-22) 403 | 404 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.2.0...v0.2.1) 405 | 406 | **Fixed bugs:** 407 | 408 | - Update @knapsack-pro/core to 0.2.1 to fix problem with wrong Knapsack Pro API endpoint url [\#3](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/3) ([ArturT](https://github.com/ArturT)) 409 | - Fix security vulnerability with npm audit fix [\#2](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/2) ([ArturT](https://github.com/ArturT)) 410 | - Filter bin files from proper out dir [\#1](https://github.com/KnapsackPro/knapsack-pro-cypress/pull/1) ([ArturT](https://github.com/ArturT)) 411 | 412 | ## [v0.2.0](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.2.0) (2018-09-15) 413 | 414 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.1.2...v0.2.0) 415 | 416 | ## [v0.1.2](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.1.2) (2018-09-14) 417 | 418 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/v0.1.1...v0.1.2) 419 | 420 | ## [v0.1.1](https://github.com/KnapsackPro/knapsack-pro-cypress/tree/v0.1.1) (2018-09-14) 421 | 422 | [Full Changelog](https://github.com/KnapsackPro/knapsack-pro-cypress/compare/2b61b43cfe89059e8ac93eaebffc7918989c09af...v0.1.1) 423 | 424 | 425 | 426 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 427 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Artur Trzop, Rafał Trzop https://knapsackpro.com 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @knapsack-pro/cypress 2 | 3 | This repository was merged into [Knapsack Pro JS](https://github.com/KnapsackPro/knapsack-pro-js). 4 | -------------------------------------------------------------------------------- /bin/setup_development: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | npm install 4 | 5 | $(npm bin)/cypress install 6 | 7 | # link deps 8 | npm link @knapsack-pro/core 9 | 10 | # build project 11 | npm run build 12 | 13 | # register @knapsack-pro/cypress package globally in your local system 14 | npm link 15 | 16 | # link deps because npm link removed it 17 | npm link @knapsack-pro/core 18 | -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | import gulp from 'gulp'; 2 | import del from 'del'; 3 | import ts from 'gulp-typescript'; 4 | import gFilter from 'gulp-filter'; 5 | import chmod from 'gulp-chmod'; 6 | 7 | const tsProject = ts.createProject('tsconfig.json'); 8 | const paths = { 9 | src: tsProject.config.include, 10 | dest: tsProject.config.compilerOptions.outDir, 11 | }; 12 | 13 | function compile() { 14 | const filterBinFiles = gFilter( 15 | `${tsProject.config.compilerOptions.outDir}/knapsack-pro-cypress.js`, 16 | { restore: true }, 17 | ); 18 | 19 | return ( 20 | tsProject 21 | .src() 22 | .pipe(tsProject()) 23 | .js // compile TypeScript to JavaScript 24 | .pipe(filterBinFiles) // filter a subset of the files 25 | // make them executable 26 | .pipe(chmod(0o755)) 27 | // bring back the previously filtered out files 28 | .pipe(filterBinFiles.restore) 29 | .pipe(gulp.dest(paths.dest)) 30 | ); 31 | } 32 | 33 | function watch() { 34 | gulp.watch(paths.src, compile); 35 | } 36 | 37 | export const clean = () => del([`${paths.dest}/**`, `!${paths.dest}`]); 38 | export const build = gulp.series(clean, compile); 39 | export const dev = gulp.series(build, watch); 40 | 41 | export default dev; 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@knapsack-pro/cypress", 3 | "version": "6.1.0", 4 | "description": "Knapsack Pro Cypress splits Cypress.io tests across CI nodes and makes sure that tests will run in optimal time on each CI node.", 5 | "keywords": [ 6 | "knapsack", 7 | "knapsack pro", 8 | "cypress", 9 | "cypress.io", 10 | "test suite parallelisation", 11 | "parallelisation", 12 | "testing", 13 | "test", 14 | "automation", 15 | "end-to-end", 16 | "e2e", 17 | "integration", 18 | "runner", 19 | "CI" 20 | ], 21 | "author": { 22 | "name": "Knapsack Sp. z o.o.", 23 | "email": "support@knapsackpro.com", 24 | "url": "https://knapsackpro.com" 25 | }, 26 | "contributors": [ 27 | { 28 | "name": "Artur Trzop", 29 | "email": "arturtrzop@gmail.com" 30 | }, 31 | { 32 | "name": "Rafał Trzop", 33 | "email": "rafaltrzop@gmail.com" 34 | } 35 | ], 36 | "license": "MIT", 37 | "scripts": { 38 | "start": "gulp", 39 | "build": "gulp build", 40 | "lint": "npm run eslint:check && npm run prettier:check", 41 | "eslint:check": "eslint . --ext .ts", 42 | "eslint:format": "eslint . --ext .ts --fix", 43 | "prettier:check": "prettier --check .", 44 | "prettier:format": "prettier --config .prettierrc.json 'src/**/*.ts' --write" 45 | }, 46 | "files": [ 47 | "/lib" 48 | ], 49 | "homepage": "https://knapsackpro.com", 50 | "repository": { 51 | "type": "git", 52 | "url": "https://github.com/KnapsackPro/knapsack-pro-cypress.git" 53 | }, 54 | "bugs": { 55 | "url": "https://github.com/KnapsackPro/knapsack-pro-cypress/issues" 56 | }, 57 | "bin": { 58 | "knapsack-pro-cypress": "lib/knapsack-pro-cypress.js" 59 | }, 60 | "dependencies": { 61 | "@knapsack-pro/core": "^5.1.0", 62 | "glob": "^8.1.0", 63 | "minimatch": "^5.1.4", 64 | "minimist": "^1.2.6", 65 | "uuid": "^8.3.2" 66 | }, 67 | "peerDependencies": { 68 | "cypress": ">=10.0.0" 69 | }, 70 | "devDependencies": { 71 | "@babel/core": "^7.18.2", 72 | "@babel/preset-env": "^7.18.2", 73 | "@babel/register": "^7.17.7", 74 | "@types/glob": "^8.0.0", 75 | "@types/jquery": "^3.5.14", 76 | "@types/node": "^17.0.41", 77 | "@typescript-eslint/eslint-plugin": "^5.27.1", 78 | "@typescript-eslint/parser": "^5.27.1", 79 | "cypress": "12.6.0", 80 | "del": "^6.1.1", 81 | "eslint": "^7.32.0", 82 | "eslint-config-airbnb-base": "^15.0.0", 83 | "eslint-config-prettier": "^8.5.0", 84 | "eslint-plugin-import": "^2.26.0", 85 | "eslint-plugin-prettier": "^4.0.0", 86 | "gulp": "^4.0.2", 87 | "gulp-chmod": "^3.0.0", 88 | "gulp-filter": "^7.0.0", 89 | "gulp-typescript": "^5.0.1", 90 | "prettier": "^2.6.2", 91 | "typescript": "^4.7.3" 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/cypress-cli.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line @typescript-eslint/no-var-requires 2 | const minimist = require('minimist'); 3 | // eslint-disable-next-line @typescript-eslint/no-var-requires 4 | const { v4: uuidv4 } = require('uuid'); 5 | 6 | export class CypressCLI { 7 | // Translate Cypress options to Cypress CLI options: 8 | // Cypress options: https://docs.cypress.io/guides/guides/command-line#Commands 9 | // Cypress CLI options (with camelCase): https://docs.cypress.io/guides/guides/module-api.html#cypress-run 10 | public static alias = { 11 | 'ci-build-id': 'ciBuildId', 12 | 'config-file': 'configFile', 13 | 'reporter-options': 'reporterOptions', 14 | 'slow-test-threshold': 'slowTestThreshold', 15 | 'testing-type': 'testingType', 16 | 'no-exit': 'noExit', 17 | }; 18 | 19 | public static argvToOptions(): object { 20 | const argv = process.argv.slice(2); 21 | 22 | return minimist(argv, { 23 | alias: CypressCLI.alias, 24 | }); 25 | } 26 | 27 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 28 | public static updateOptions(args: any): object { 29 | // If you want to send recorded data to Cypress Dashboard 30 | // then we need to generate a unique group name for set of tests fetched 31 | // from Knapsack Pro API for each cypress.run execution 32 | // Only then Cypress API accepts data 33 | // (Cypress not allow to use the same group name within the same CI build) 34 | // eslint-disable-next-line no-prototype-builtins 35 | if (args.hasOwnProperty('record') && args.record !== 'false') { 36 | return { 37 | ...args, 38 | group: uuidv4(), 39 | }; 40 | } 41 | 42 | return args; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/env-config.ts: -------------------------------------------------------------------------------- 1 | export class EnvConfig { 2 | public static loadEnvironmentVariables(): void { 3 | if (process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS) { 4 | process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN = 5 | process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS; 6 | } 7 | } 8 | 9 | public static get testFilePattern(): string { 10 | if (process.env.KNAPSACK_PRO_TEST_FILE_PATTERN) { 11 | return process.env.KNAPSACK_PRO_TEST_FILE_PATTERN; 12 | } 13 | 14 | return 'cypress/e2e/**/*.{js,jsx,coffee,cjsx}'; 15 | } 16 | 17 | public static get testFileExcludePattern(): void | string { 18 | return process.env.KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/knapsack-pro-cypress.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import { 4 | KnapsackProCore, 5 | KnapsackProLogger, 6 | testFilesToExecuteType, 7 | onQueueFailureType, 8 | onQueueSuccessType, 9 | TestFile, 10 | } from '@knapsack-pro/core'; 11 | import { EnvConfig } from './env-config'; 12 | import { TestFilesFinder } from './test-files-finder'; 13 | import { CypressCLI } from './cypress-cli'; 14 | 15 | // eslint-disable-next-line @typescript-eslint/no-var-requires 16 | const cypress = require('cypress'); 17 | 18 | // eslint-disable-next-line @typescript-eslint/no-var-requires 19 | const { name: clientName, version: clientVersion } = require('../package.json'); 20 | 21 | const cypressCLIOptions = CypressCLI.argvToOptions(); 22 | const knapsackProLogger = new KnapsackProLogger(); 23 | 24 | knapsackProLogger.debug( 25 | `Initial Cypress CLI options:\n${KnapsackProLogger.objectInspect( 26 | cypressCLIOptions, 27 | )}`, 28 | ); 29 | 30 | EnvConfig.loadEnvironmentVariables(); 31 | 32 | const testFilesToExecute: testFilesToExecuteType = () => 33 | TestFilesFinder.allTestFiles(); 34 | const knapsackPro = new KnapsackProCore( 35 | clientName, 36 | clientVersion, 37 | testFilesToExecute, 38 | ); 39 | 40 | const onSuccess: onQueueSuccessType = async (queueTestFiles: TestFile[]) => { 41 | const testFilePaths: string[] = queueTestFiles.map( 42 | (testFile: TestFile) => testFile.path, 43 | ); 44 | 45 | const updatedCypressCLIOptions = CypressCLI.updateOptions(cypressCLIOptions); 46 | knapsackProLogger.debug( 47 | `Updated Cypress CLI options for the set of tests fetched from Knapsack Pro API:\n${KnapsackProLogger.objectInspect( 48 | updatedCypressCLIOptions, 49 | )}`, 50 | ); 51 | 52 | const { runs: tests, totalFailed } = await cypress 53 | .run({ 54 | ...updatedCypressCLIOptions, 55 | spec: testFilePaths, 56 | }) 57 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 58 | .catch((e: any) => { 59 | knapsackProLogger.error( 60 | `Error from cypress.run:\n${KnapsackProLogger.objectInspect(e)}`, 61 | ); 62 | process.exitCode = 1; 63 | throw new Error('cypress.run process failed. See the above logs.'); 64 | }); 65 | 66 | // when Cypress crashed 67 | if (typeof tests === 'undefined') { 68 | return { 69 | recordedTestFiles: [], 70 | isTestSuiteGreen: false, 71 | }; 72 | } 73 | 74 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 75 | const recordedTestFiles: TestFile[] = tests.map((test: any) => ({ 76 | path: test.spec.relative, 77 | time_execution: test.stats.duration / 1000, 78 | })); 79 | 80 | return { 81 | recordedTestFiles, 82 | isTestSuiteGreen: totalFailed === 0, 83 | }; 84 | }; 85 | 86 | // we do nothing when error so pass noop 87 | // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function 88 | const onError: onQueueFailureType = (error: any) => {}; 89 | 90 | knapsackPro.runQueueMode(onSuccess, onError); 91 | -------------------------------------------------------------------------------- /src/test-files-finder.ts: -------------------------------------------------------------------------------- 1 | import glob = require('glob'); 2 | import minimatch = require('minimatch'); 3 | 4 | import { KnapsackProLogger, TestFile } from '@knapsack-pro/core'; 5 | import { EnvConfig } from './env-config'; 6 | import * as Urls from './urls'; 7 | 8 | export class TestFilesFinder { 9 | public static allTestFiles(): TestFile[] { 10 | const testFiles = glob 11 | .sync(EnvConfig.testFilePattern) 12 | .filter((testFilePath: string) => { 13 | if (EnvConfig.testFileExcludePattern) { 14 | return !minimatch(testFilePath, EnvConfig.testFileExcludePattern, { 15 | matchBase: true, 16 | }); 17 | } 18 | return true; 19 | }) 20 | .map((testFilePath: string) => ({ path: testFilePath })); 21 | 22 | if (testFiles.length === 0) { 23 | const knapsackProLogger = new KnapsackProLogger(); 24 | 25 | const errorMessage = `Test files cannot be found.\nPlease make sure that KNAPSACK_PRO_TEST_FILE_PATTERN and KNAPSACK_PRO_TEST_FILE_IGNORE_PATTERN allow for some files in your test directory structure to be matched.\nLearn more: ${Urls.NO_TESTS_FOUND}`; 26 | 27 | knapsackProLogger.error(errorMessage); 28 | throw errorMessage; 29 | } 30 | 31 | return testFiles; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/urls.ts: -------------------------------------------------------------------------------- 1 | export const NO_TESTS_FOUND = 2 | 'https://knapsackpro.com/perma/cypress/no-tests-found'; 3 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "outDir": "lib", 5 | "removeComments": true, 6 | "target": "es5", 7 | "lib": ["es2015", "es2016.array.include", "dom"] 8 | }, 9 | "include": ["src/**/*.ts"] 10 | } 11 | --------------------------------------------------------------------------------