Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
package-lock.json
semgrep.sarif
.DS_Store
24 changes: 18 additions & 6 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env node

import fs from 'fs'
import rimraf from "rimraf";
import { rimrafSync } from "rimraf";
import path from 'path'
import codeExport from './browserstack-mocha-export.mjs'
import { project as projectProcessor } from '@seleniumhq/side-code-export'
import pkg from '@seleniumhq/side-utils';
import commander from 'commander';
import logger from 'cli-logger';
import glob from 'glob';
import { globSync } from 'glob';
import spawn from 'cross-spawn';
import * as dotenv from 'dotenv';
import { exit } from 'process';
import sanitize from 'sanitize-filename';
import { fileURLToPath } from 'url';

dotenv.config();
commander
Expand All @@ -36,14 +37,14 @@ var log = logger(conf);

const sideFiles = [
...commander.args.reduce((projects, project) => {
glob.sync(project).forEach(p => {
globSync(project).forEach(p => {
projects.add(p)
})
return projects
}, new Set()),
];

rimraf.sync(options.buildFolderPath)
rimrafSync(options.buildFolderPath)
fs.mkdirSync(options.buildFolderPath);

function readFile(filename) {
Expand Down Expand Up @@ -90,9 +91,20 @@ var reporter = []
if (options.outputFormat && options.outputFile)
reporter = ['--reporter', options.outputFormat, '--reporter-options', 'output=' + options.outputFile]

const testSuiteProcess = spawn.sync('npx', ['browserstack-node-sdk', 'mocha', '_generated', '--timeouts', options.testTimeout, '-g', options.filter, '--browserstack.config', options.browserstackConfig, ...reporter], { stdio: 'inherit', env: { ...process.env, testTimeout: options.testTimeout } });
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const browserstackSdkPath = path.join(__dirname, 'node_modules', '.bin', 'browserstack-node-sdk');
const sideRunnerNodeModules = path.join(__dirname, 'node_modules');

const testSuiteProcess = spawn.sync(browserstackSdkPath, ['mocha', '_generated', '--timeouts', options.testTimeout, '-g', options.filter, '--browserstack.config', options.browserstackConfig, ...reporter], {
stdio: 'inherit',
env: {
...process.env,
testTimeout: options.testTimeout,
NODE_PATH: `${sideRunnerNodeModules}${path.delimiter}${process.env.NODE_PATH || ''}`
}
});

if (!options.debug) {
rimraf.sync(options.buildFolderPath)
rimrafSync(options.buildFolderPath)
}
exit(testSuiteProcess.status)
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "git+https://github.com/BrowserStackCE/browserstack-side-runner.git"
},
"version": "2.2.2",
"version": "2.3.0",
"main": "index.mjs",
"homepage": "https://github.com/BrowserStackCE/browserstack-side-runner#readme",
"scripts": {
Expand All @@ -13,6 +13,9 @@
"bin": {
"browserstack-side-runner": "index.mjs"
},
"engines": {
"node": ">=18"
},
"author": "",
"license": "ISC",
"description": "",
Expand All @@ -21,18 +24,18 @@
"@seleniumhq/code-export-javascript-mocha": "^4.0.0-alpha.4",
"@seleniumhq/side-code-export": "^4.0.0-alpha.3",
"@seleniumhq/side-utils": "^3.17.2",
"browserstack-node-sdk": "^1.32.0",
"browserstack-node-sdk": "^1.40.8",
"cli-logger": "^0.5.40",
"commander": "^8.0.0",
"cross-spawn": "^7.0.3",
"dotenv": "^16.0.3",
"glob": "^11.0.3",
"glob": "^10.4.5",
"js-yaml": "^4.1.0",
"mocha": "^8.4.0",
"mocha-multi-reporters": "^1.5.1",
"rfdc": "^1.3.0",
"rimraf": "^6.0.1",
"rimraf": "^5.0.9",
"sanitize-filename": "^1.6.3",
"selenium-webdriver": "^4.1.1"
"selenium-webdriver": "^4.5.0"
}
}