From b06c3c5c4c001170651691ab9c6d7f7b67a2a816 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Tue, 5 May 2020 19:40:42 +0530 Subject: [PATCH 01/19] adding package.json into template and archive --- bin/helpers/archiver.js | 5 ++++- bin/templates/configTemplate.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 3f9fea9c..244cbfe4 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -8,6 +8,7 @@ const archiveSpecs = (runSettings, filePath) => { var output = fs.createWriteStream(filePath); var cypressFolderPath = runSettings.cypress_proj_dir + var packageJsonPath = runSettings.package_json_path var archive = archiver('zip', { zlib: { level: 9 } // Sets the compression level. @@ -37,7 +38,9 @@ const archiveSpecs = (runSettings, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }); + archive + .glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }) + .append(packageJsonPath, { name: 'package.json' }); }); archive.finalize(); diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index ceacf659..c0ff3fa7 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -12,7 +12,8 @@ module.exports = function () { } ], "run_settings": { - "cypress_proj_dir" : "/path/to/cypress.json", + "package_json_path": "/path/to/package.json", + "cypress_proj_dir" : "/dir/to/cypress.json", "project": "project-name", "customBuildName": "build-name" }, From de1ee127f79cd299e6bbd8851ce3a4a7f453b0cf Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Tue, 5 May 2020 19:41:05 +0530 Subject: [PATCH 02/19] Updating readme with package.json instructions and callbackURL --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf11ef70..5c58bcb1 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ - [Configuring your tests](#configuring-your-tests) - [Running the tests](#running-the-tests) - [Getting build information](#getting-build-information) + - [Stopping a running build](#stopping-a-running-build) - [Limitations](#limitations) - [Accessing test results](#accessing-test-results) - [License](#license) @@ -78,10 +79,12 @@ The following table provides a reference for all the options that can be provide | `versions` | A list of browser versions that you want to run your tests on.

**Example:** To run on versions 69, 67 and 65 provide `["69", "67", "65"]` | Right now edge 80 and all chrome versions from 66 to 78 are supported | | `specs`
(_deprecated_) | This param is deprecated in favour of a more complete `cypress_proj_dir` param. The path to the spec files that need to be run on BrowserStack | Takes a list of strings that point to location of the spec files | | `cypress_proj_dir` | Path to the folder which contains `cypress.json` file. This path will be considered as the root path of the project. |- | +| `package_json_path` | Absolute path to the `package.json` file of your application which uses cypress in its development dependency. This is used for resolving development dependecies before running the tests. |- | | `project` | Name of your project. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the project name. | A string providing the name of the project | | `customBuildName` | Helps in providing a custom name for the build. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the build name. | A string providing the name of the build | | `local` | Helps in testing websites that cannot be accessed in public network. If you set this to `true`, please download the Local binary and establish a local connection first (you can learn how to do so [here](https://www.browserstack.com/local-testing/automate#command-line)) | Boolean: `true` / `false`. Set this to `true` if you need to test a local website. Set this to `false` if the website is accessible publicly. | | `localIdentifier` | The BrowserStack Local tunnel that should be used to resolve requests. This is applicable only when you start a Local binary with a local identifier. Your tests might fail if you use an invalid local identifier. This option will be ignored if `local` option is set to `false`. | A string if a tunnel identified by the Local identifier should be used (should be same as the one used to start the Local binary). Set this to `null` (default value) to resolve requests using Local without a Local identifier. | +| `callbackURL` | A callback URL which can be used as a hook to update your server about the build's status. A POST request will be made to this URL with tests data and their status in its body once the tests are completed. | A string which is a valid URI. The endpoint must accept the POST method. | ### Running the tests You can start running your test build using the following command. @@ -212,7 +215,7 @@ Output: - `exec` and `task` are not allowed. - While using local, please make sure to create `/etc/hosts` entry pointing to some URL, and use that URL in the tests. The `localhost` URI doesn't work at the moment. -- Installing custom npm packages are not supported at this moment. +- Installing custom npm packages are not supported on Mac OS X at this moment. # Accessing test results From 25a7b41480e102d8cf50844bef94b2e232a7e561 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 8 May 2020 17:53:07 +0530 Subject: [PATCH 03/19] Adding config template with cypress dependencies as key in browserstack.json Removed package.json key dependency. Added config update command to update browserstack.json gracefully. --- bin/commands/updateConfig.js | 46 +++++++++++++++++++++++++++++++++ bin/helpers/constants.js | 5 ++++ bin/runner.js | 20 ++++++++++++++ bin/templates/configTemplate.js | 3 ++- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 bin/commands/updateConfig.js diff --git a/bin/commands/updateConfig.js b/bin/commands/updateConfig.js new file mode 100644 index 00000000..4eea92ef --- /dev/null +++ b/bin/commands/updateConfig.js @@ -0,0 +1,46 @@ +'use strict'; +var config = require('../helpers/config'); +var request = require('request') +var logger = require("../helpers/logger"); +var Constants = require("../helpers/constants") +var fileHelpers = require('../helpers/fileHelpers'); +var capabilityHelper = require("../helpers/capabilityHelper"); + + +let updateConfig = function(args) { + let bsConfigPath = process.cwd() + args.cf; + logger.log(`Updating config from ${args.cf}`); + + var currentConfig = require(bsConfigPath); + + var configTemplate = require('../templates/configTemplate')() + var newConfig = JSON.parse(configTemplate); + + function allDone() { + logger.log(Constants.userMessages.CONFIG_FILE_CREATED); + } + + capabilityHelper.validate(currentConfig).then(function (validatedConfig) { + logger.log(`${currentConfig}`); + + for (const key in newConfig) { + if (currentConfig[key] === undefined) { + currentConfig[key] = newConfig[key] + } + } + + var EOL = require('os').EOL + var file = [ + JSON.stringify(currentConfig, null, 4) + ].join(EOL) + + var config = { + file: file, + path: bsConfigPath + }; + + fileHelpers.write(config, null, allDone); + }); +} + +module.exports = updateConfig; diff --git a/bin/helpers/constants.js b/bin/helpers/constants.js index 6bf362a1..9edf19d9 100644 --- a/bin/helpers/constants.js +++ b/bin/helpers/constants.js @@ -47,6 +47,11 @@ const cliMessages = { INFO: "Run your tests on BrowserStack.", DESC: "Path to BrowserStack config", CONFIG_DEMAND: "config file is required" + }, + UPDATE_CONFIG: { + INFO: "Updates the browserstack.json with the latest version", + CONFIG_DEMAND_DESC: "Path to BrowserStack config", + CONFIG_DEMAND: "config file is required" } } diff --git a/bin/runner.js b/bin/runner.js index 2985dbfc..9bd084d9 100755 --- a/bin/runner.js +++ b/bin/runner.js @@ -37,6 +37,26 @@ var argv = yargs return require('./commands/init')(argv); } }) + .command('update-config', Constants.cliMessages.UPDATE_CONFIG.INFO, function(yargs) { + argv = yargs + .usage('usage: $0 update-config') + .options('cf', { + alias: 'config-file', + describe: Constants.cliMessages.UPDATE_CONFIG.CONFIG_DEMAND_DESC, + default: '/browserstack.json', + type: 'string', + nargs: 1, + demand: true, + demand: Constants.cliMessages.UPDATE_CONFIG.CONFIG_DEMAND + }) + .help('help') + .wrap(null) + .argv + + if (checkCommands(yargs, argv, 1)) { + return require('./commands/updateConfig')(argv); + } + }) .command('build-info', Constants.cliMessages.BUILD.INFO, function(yargs) { argv = yargs .usage('usage: $0 ') diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index c0ff3fa7..a213480b 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -12,7 +12,6 @@ module.exports = function () { } ], "run_settings": { - "package_json_path": "/path/to/package.json", "cypress_proj_dir" : "/dir/to/cypress.json", "project": "project-name", "customBuildName": "build-name" @@ -20,6 +19,8 @@ module.exports = function () { "connection_settings": { "local": false, "localIdentifier": null + }, + "cypress_dependencies": { } } var EOL = require('os').EOL From 48c544cc3ab3368bfec160b2c2221997c026da5f Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 8 May 2020 17:57:54 +0530 Subject: [PATCH 04/19] removed packagejson path and added cypress_dependencies to the document --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c58bcb1..cdbc055b 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following table provides a reference for all the options that can be provide | `versions` | A list of browser versions that you want to run your tests on.

**Example:** To run on versions 69, 67 and 65 provide `["69", "67", "65"]` | Right now edge 80 and all chrome versions from 66 to 78 are supported | | `specs`
(_deprecated_) | This param is deprecated in favour of a more complete `cypress_proj_dir` param. The path to the spec files that need to be run on BrowserStack | Takes a list of strings that point to location of the spec files | | `cypress_proj_dir` | Path to the folder which contains `cypress.json` file. This path will be considered as the root path of the project. |- | -| `package_json_path` | Absolute path to the `package.json` file of your application which uses cypress in its development dependency. This is used for resolving development dependecies before running the tests. |- | +| `cypress_dependencies` | List your node packages dependencies in `cypress_dependencies`. You may copy-paste all dependencies(including their versions) required to run your Cypress tests from `package.json` file. | - | | `project` | Name of your project. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the project name. | A string providing the name of the project | | `customBuildName` | Helps in providing a custom name for the build. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the build name. | A string providing the name of the build | | `local` | Helps in testing websites that cannot be accessed in public network. If you set this to `true`, please download the Local binary and establish a local connection first (you can learn how to do so [here](https://www.browserstack.com/local-testing/automate#command-line)) | Boolean: `true` / `false`. Set this to `true` if you need to test a local website. Set this to `false` if the website is accessible publicly. | From b8a462560b14e79c699924adefde2b2f699e0408 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 8 May 2020 18:22:56 +0530 Subject: [PATCH 05/19] changing cypress_dependencies to npm_dependencies --- README.md | 2 +- bin/templates/configTemplate.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cdbc055b..2d15e368 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The following table provides a reference for all the options that can be provide | `versions` | A list of browser versions that you want to run your tests on.

**Example:** To run on versions 69, 67 and 65 provide `["69", "67", "65"]` | Right now edge 80 and all chrome versions from 66 to 78 are supported | | `specs`
(_deprecated_) | This param is deprecated in favour of a more complete `cypress_proj_dir` param. The path to the spec files that need to be run on BrowserStack | Takes a list of strings that point to location of the spec files | | `cypress_proj_dir` | Path to the folder which contains `cypress.json` file. This path will be considered as the root path of the project. |- | -| `cypress_dependencies` | List your node packages dependencies in `cypress_dependencies`. You may copy-paste all dependencies(including their versions) required to run your Cypress tests from `package.json` file. | - | +| `npm_dependencies` | List your node packages dependencies in `npm_dependencies`. You may copy-paste all dependencies(including their versions) required to run your Cypress tests from `package.json` file. | - | | `project` | Name of your project. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the project name. | A string providing the name of the project | | `customBuildName` | Helps in providing a custom name for the build. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the build name. | A string providing the name of the build | | `local` | Helps in testing websites that cannot be accessed in public network. If you set this to `true`, please download the Local binary and establish a local connection first (you can learn how to do so [here](https://www.browserstack.com/local-testing/automate#command-line)) | Boolean: `true` / `false`. Set this to `true` if you need to test a local website. Set this to `false` if the website is accessible publicly. | diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index a213480b..851e0331 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -20,7 +20,7 @@ module.exports = function () { "local": false, "localIdentifier": null }, - "cypress_dependencies": { + "npm_dependencies": { } } var EOL = require('os').EOL From 59f7ba3082260fd49a1e883400ac7c743b2333f1 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 8 May 2020 20:58:12 +0530 Subject: [PATCH 06/19] send npm_dependencies to archiver --- bin/commands/runs.js | 4 ++-- bin/helpers/archiver.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/commands/runs.js b/bin/commands/runs.js index 37a45641..ca8b3d93 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -18,7 +18,7 @@ function deleteZip() { logger.log(Constants.userMessages.ZIP_DELETE_FAILED); } else { logger.log(Constants.userMessages.ZIP_DELETED); - } + } }); } @@ -31,7 +31,7 @@ function runCypress(args) { capabilityHelper.validate(bsConfig).then(function (validated) { logger.log(validated); // Archive the spec files - archiver.archive(bsConfig.run_settings, config.fileName).then(function (data) { + archiver.archive(bsConfig, config.fileName).then(function (data) { // Uploaded zip file zipUploader.zipUpload(bsConfig, config.fileName).then(function (zip) { // Create build diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 244cbfe4..17d9c333 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -3,12 +3,11 @@ const fs = require('fs'), archiver = require('archiver'), logger = require("./logger"); -const archiveSpecs = (runSettings, filePath) => { +const archiveSpecs = (bsConfig, filePath) => { return new Promise(function (resolve, reject) { var output = fs.createWriteStream(filePath); - var cypressFolderPath = runSettings.cypress_proj_dir - var packageJsonPath = runSettings.package_json_path + var cypressFolderPath = bsConfig.run_settings.cypress_proj_dir var archive = archiver('zip', { zlib: { level: 9 } // Sets the compression level. @@ -36,11 +35,13 @@ const archiveSpecs = (runSettings, filePath) => { archive.pipe(output); + var packageJSON = JSON.stringify({devDependencies: bsConfig.npm_dependencies}, null, 4); + let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { archive .glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }) - .append(packageJsonPath, { name: 'package.json' }); + .append(packageJSON, { name: 'package.json' }); }); archive.finalize(); From e65dd49238b8267fdf3a46a9ce5ebd1b5b64d6c7 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 8 May 2020 20:58:47 +0530 Subject: [PATCH 07/19] remove unncessary require --- bin/commands/updateConfig.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/commands/updateConfig.js b/bin/commands/updateConfig.js index 4eea92ef..fe165d60 100644 --- a/bin/commands/updateConfig.js +++ b/bin/commands/updateConfig.js @@ -1,6 +1,4 @@ 'use strict'; -var config = require('../helpers/config'); -var request = require('request') var logger = require("../helpers/logger"); var Constants = require("../helpers/constants") var fileHelpers = require('../helpers/fileHelpers'); From cc04cbf73d6e31b6d0f47a17dd9d95d2d1ac529c Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Mon, 11 May 2020 11:59:12 +0530 Subject: [PATCH 08/19] fix - archive the package.json before finalize() --- bin/helpers/archiver.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 17d9c333..42da5ce7 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -39,10 +39,9 @@ const archiveSpecs = (bsConfig, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive - .glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }) - .append(packageJSON, { name: 'package.json' }); + archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }) }); + archive.append(packageJSON, { name: 'package.json' }); archive.finalize(); }); From 8b5e5d481682f4f4133f81c4054cb4138e6d763e Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Mon, 11 May 2020 12:12:36 +0530 Subject: [PATCH 09/19] adding missing semicolon --- bin/helpers/archiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 42da5ce7..85cf7f0f 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -39,7 +39,7 @@ const archiveSpecs = (bsConfig, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }) + archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }); }); archive.append(packageJSON, { name: 'package.json' }); From 767a4fac67c60dcc8add5d2988710e4566aae3b1 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Wed, 13 May 2020 20:49:01 +0530 Subject: [PATCH 10/19] reverting update config command, moving npm_dependencies to run settings --- bin/commands/runs.js | 2 +- bin/commands/updateConfig.js | 44 --------------------------------- bin/helpers/archiver.js | 6 ++--- bin/runner.js | 20 --------------- bin/templates/configTemplate.js | 6 ++--- 5 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 bin/commands/updateConfig.js diff --git a/bin/commands/runs.js b/bin/commands/runs.js index ca8b3d93..22594274 100644 --- a/bin/commands/runs.js +++ b/bin/commands/runs.js @@ -31,7 +31,7 @@ function runCypress(args) { capabilityHelper.validate(bsConfig).then(function (validated) { logger.log(validated); // Archive the spec files - archiver.archive(bsConfig, config.fileName).then(function (data) { + archiver.archive(bsConfig.run_settings, config.fileName).then(function (data) { // Uploaded zip file zipUploader.zipUpload(bsConfig, config.fileName).then(function (zip) { // Create build diff --git a/bin/commands/updateConfig.js b/bin/commands/updateConfig.js deleted file mode 100644 index fe165d60..00000000 --- a/bin/commands/updateConfig.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; -var logger = require("../helpers/logger"); -var Constants = require("../helpers/constants") -var fileHelpers = require('../helpers/fileHelpers'); -var capabilityHelper = require("../helpers/capabilityHelper"); - - -let updateConfig = function(args) { - let bsConfigPath = process.cwd() + args.cf; - logger.log(`Updating config from ${args.cf}`); - - var currentConfig = require(bsConfigPath); - - var configTemplate = require('../templates/configTemplate')() - var newConfig = JSON.parse(configTemplate); - - function allDone() { - logger.log(Constants.userMessages.CONFIG_FILE_CREATED); - } - - capabilityHelper.validate(currentConfig).then(function (validatedConfig) { - logger.log(`${currentConfig}`); - - for (const key in newConfig) { - if (currentConfig[key] === undefined) { - currentConfig[key] = newConfig[key] - } - } - - var EOL = require('os').EOL - var file = [ - JSON.stringify(currentConfig, null, 4) - ].join(EOL) - - var config = { - file: file, - path: bsConfigPath - }; - - fileHelpers.write(config, null, allDone); - }); -} - -module.exports = updateConfig; diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 85cf7f0f..64c8130a 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -3,11 +3,11 @@ const fs = require('fs'), archiver = require('archiver'), logger = require("./logger"); -const archiveSpecs = (bsConfig, filePath) => { +const archiveSpecs = (runSettings, filePath) => { return new Promise(function (resolve, reject) { var output = fs.createWriteStream(filePath); - var cypressFolderPath = bsConfig.run_settings.cypress_proj_dir + var cypressFolderPath = runSettings.cypress_proj_dir; var archive = archiver('zip', { zlib: { level: 9 } // Sets the compression level. @@ -35,7 +35,7 @@ const archiveSpecs = (bsConfig, filePath) => { archive.pipe(output); - var packageJSON = JSON.stringify({devDependencies: bsConfig.npm_dependencies}, null, 4); + var packageJSON = JSON.stringify({devDependencies: runSettings.npm_dependencies}, null, 4); let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { diff --git a/bin/runner.js b/bin/runner.js index 9bd084d9..2985dbfc 100755 --- a/bin/runner.js +++ b/bin/runner.js @@ -37,26 +37,6 @@ var argv = yargs return require('./commands/init')(argv); } }) - .command('update-config', Constants.cliMessages.UPDATE_CONFIG.INFO, function(yargs) { - argv = yargs - .usage('usage: $0 update-config') - .options('cf', { - alias: 'config-file', - describe: Constants.cliMessages.UPDATE_CONFIG.CONFIG_DEMAND_DESC, - default: '/browserstack.json', - type: 'string', - nargs: 1, - demand: true, - demand: Constants.cliMessages.UPDATE_CONFIG.CONFIG_DEMAND - }) - .help('help') - .wrap(null) - .argv - - if (checkCommands(yargs, argv, 1)) { - return require('./commands/updateConfig')(argv); - } - }) .command('build-info', Constants.cliMessages.BUILD.INFO, function(yargs) { argv = yargs .usage('usage: $0 ') diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index 851e0331..4ef7721a 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -14,14 +14,14 @@ module.exports = function () { "run_settings": { "cypress_proj_dir" : "/dir/to/cypress.json", "project": "project-name", - "customBuildName": "build-name" + "customBuildName": "build-name", + "npm_dependencies": { + } }, "connection_settings": { "local": false, "localIdentifier": null }, - "npm_dependencies": { - } } var EOL = require('os').EOL var file = [ From f8797a7aec3cdff69ddb6511ec47dfc150b7b9d9 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Wed, 13 May 2020 20:51:18 +0530 Subject: [PATCH 11/19] fixing incorrect JSON object --- bin/templates/configTemplate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/templates/configTemplate.js b/bin/templates/configTemplate.js index 4ef7721a..5ea24f9b 100644 --- a/bin/templates/configTemplate.js +++ b/bin/templates/configTemplate.js @@ -21,7 +21,7 @@ module.exports = function () { "connection_settings": { "local": false, "localIdentifier": null - }, + } } var EOL = require('os').EOL var file = [ From 0e25691cb2412eb6492483f14a4b7d0277b74ff7 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Thu, 14 May 2020 13:16:23 +0530 Subject: [PATCH 12/19] fix package-lock.json to not being included in the tests.zip --- bin/helpers/archiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 64c8130a..ff3e133b 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -39,7 +39,7 @@ const archiveSpecs = (runSettings, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: 'node_modules/**' }); + archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json'] }); }); archive.append(packageJSON, { name: 'package.json' }); From 00ba6708a0b043f5ae41e3bd36152200f9c1b7a5 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 15 May 2020 13:16:44 +0530 Subject: [PATCH 13/19] ignore existing package.json as well --- bin/helpers/archiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index ff3e133b..301bd7e2 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -39,7 +39,7 @@ const archiveSpecs = (runSettings, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json'] }); + archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json'] }); }); archive.append(packageJSON, { name: 'package.json' }); From 8406d6375ce7828ed8626fe69f4be71f32eec2e4 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 15 May 2020 15:56:23 +0530 Subject: [PATCH 14/19] changing the package.json to browserstack-package.json --- bin/helpers/archiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 301bd7e2..90e49702 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -41,7 +41,7 @@ const archiveSpecs = (runSettings, filePath) => { allowedFileTypes.forEach(fileType => { archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json'] }); }); - archive.append(packageJSON, { name: 'package.json' }); + archive.append(packageJSON, { name: 'browserstack-package.json' }); archive.finalize(); }); From e82dfc5bd6355eebcc92c2fb1294d7e150c5143c Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 15 May 2020 15:57:47 +0530 Subject: [PATCH 15/19] reverting constants for update-config command --- bin/helpers/constants.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bin/helpers/constants.js b/bin/helpers/constants.js index 9edf19d9..6bf362a1 100644 --- a/bin/helpers/constants.js +++ b/bin/helpers/constants.js @@ -47,11 +47,6 @@ const cliMessages = { INFO: "Run your tests on BrowserStack.", DESC: "Path to BrowserStack config", CONFIG_DEMAND: "config file is required" - }, - UPDATE_CONFIG: { - INFO: "Updates the browserstack.json with the latest version", - CONFIG_DEMAND_DESC: "Path to BrowserStack config", - CONFIG_DEMAND: "config file is required" } } From ff1c23ac28ff8c226c2f56573a39653c1072d11b Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 15 May 2020 16:03:28 +0530 Subject: [PATCH 16/19] reverting the readme doc --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2d15e368..db83a903 100644 --- a/README.md +++ b/README.md @@ -79,12 +79,10 @@ The following table provides a reference for all the options that can be provide | `versions` | A list of browser versions that you want to run your tests on.

**Example:** To run on versions 69, 67 and 65 provide `["69", "67", "65"]` | Right now edge 80 and all chrome versions from 66 to 78 are supported | | `specs`
(_deprecated_) | This param is deprecated in favour of a more complete `cypress_proj_dir` param. The path to the spec files that need to be run on BrowserStack | Takes a list of strings that point to location of the spec files | | `cypress_proj_dir` | Path to the folder which contains `cypress.json` file. This path will be considered as the root path of the project. |- | -| `npm_dependencies` | List your node packages dependencies in `npm_dependencies`. You may copy-paste all dependencies(including their versions) required to run your Cypress tests from `package.json` file. | - | | `project` | Name of your project. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the project name. | A string providing the name of the project | | `customBuildName` | Helps in providing a custom name for the build. This will be displayed in your Automate dashboard, and you'll be able to search & filter your tests based on the build name. | A string providing the name of the build | | `local` | Helps in testing websites that cannot be accessed in public network. If you set this to `true`, please download the Local binary and establish a local connection first (you can learn how to do so [here](https://www.browserstack.com/local-testing/automate#command-line)) | Boolean: `true` / `false`. Set this to `true` if you need to test a local website. Set this to `false` if the website is accessible publicly. | | `localIdentifier` | The BrowserStack Local tunnel that should be used to resolve requests. This is applicable only when you start a Local binary with a local identifier. Your tests might fail if you use an invalid local identifier. This option will be ignored if `local` option is set to `false`. | A string if a tunnel identified by the Local identifier should be used (should be same as the one used to start the Local binary). Set this to `null` (default value) to resolve requests using Local without a Local identifier. | -| `callbackURL` | A callback URL which can be used as a hook to update your server about the build's status. A POST request will be made to this URL with tests data and their status in its body once the tests are completed. | A string which is a valid URI. The endpoint must accept the POST method. | ### Running the tests You can start running your test build using the following command. From 096789117b351d2a0c1f4ae03cb301119d6804da Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Fri, 15 May 2020 16:12:11 +0530 Subject: [PATCH 17/19] reverting the readme doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db83a903..e5e250e1 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Output: - `exec` and `task` are not allowed. - While using local, please make sure to create `/etc/hosts` entry pointing to some URL, and use that URL in the tests. The `localhost` URI doesn't work at the moment. -- Installing custom npm packages are not supported on Mac OS X at this moment. +- Installing custom npm packages are not supported at this moment. # Accessing test results From f23ae64c5d2911cb2ec2bdaebb7bad51a3323ef6 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Mon, 18 May 2020 18:44:35 +0530 Subject: [PATCH 18/19] ignore browserstack-package.json file --- bin/helpers/archiver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 7d3e2ee5..4c0d64a5 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -40,7 +40,7 @@ const archiveSpecs = (runSettings, filePath) => { let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { - archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json'] }); + archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json'] }); }); archive.append(packageJSON, { name: 'browserstack-package.json' }); From acc919f3fd6c70e659bcea889314790c42588f27 Mon Sep 17 00:00:00 2001 From: Surya Tripathi Date: Thu, 21 May 2020 15:20:31 +0530 Subject: [PATCH 19/19] add npm dependencies only when it is provided in config --- bin/helpers/archiver.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/helpers/archiver.js b/bin/helpers/archiver.js index 4c0d64a5..da6bf816 100644 --- a/bin/helpers/archiver.js +++ b/bin/helpers/archiver.js @@ -36,13 +36,16 @@ const archiveSpecs = (runSettings, filePath) => { archive.pipe(output); - var packageJSON = JSON.stringify({devDependencies: runSettings.npm_dependencies}, null, 4); let allowedFileTypes = [ 'js', 'json', 'txt', 'ts' ] allowedFileTypes.forEach(fileType => { archive.glob(`**/*.${fileType}`, { cwd: cypressFolderPath, matchBase: true, ignore: ['node_modules/**', 'package-lock.json', 'package.json', 'browserstack-package.json'] }); }); - archive.append(packageJSON, { name: 'browserstack-package.json' }); + + if (typeof runSettings.npm_dependencies === 'object') { + var packageJSON = JSON.stringify({devDependencies: runSettings.npm_dependencies}, null, 4); + archive.append(packageJSON, { name: 'browserstack-package.json' }); + } archive.finalize(); });