Skip to content

Commit 8b0379a

Browse files
committed
Enhance error messaging in the side-runner
1 parent 3586588 commit 8b0379a

File tree

12 files changed

+71
-51
lines changed

12 files changed

+71
-51
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"test:e2e": "jest --testMatch \"**/packages/**/__tests__/**/*.e2e.js\"",
1717
"lint": "pnpm run lint:scripts",
1818
"lint:scripts": "eslint --ignore-pattern node_modules --ignore-pattern third-party --ignore-pattern dist --ignore-pattern build --ignore-pattern json --ext .ts,.tsx --ext .js packages/",
19-
"test:side-runner": "npm-run-bg 'http-server ./tests/static::Available on::8080' 'node ./packages/side-runner/dist/bin.js -t 15000 ./tests/examples/*.side'",
20-
"test:side-runner:ci": "npm-run-bg 'http-server ./tests/static::Available on::8080' 'node ./packages/side-runner/dist/bin.js -c \"goog:chromeOptions.args=[headless,no-sandbox] browserName=chrome\" -t 15000 ./tests/examples/*.side'",
19+
"test:side-runner": "npm-run-bg -s 'http-server -p 8080 ./tests/static::Available on::8080' 'node ./packages/side-runner/dist/bin.js -t 15000 ./tests/examples/nginx-examples.side.ex'",
20+
"test:side-runner:ci": "npm-run-bg -s 'http-server -p 8080 ./tests/static::Available on::8080' 'node ./packages/side-runner/dist/bin.js -c \"goog:chromeOptions.args=[headless,no-sandbox] browserName=chrome\" -t 15000 ./tests/examples/*.side'",
2121
"typecheck": "tsc --noEmit --composite false",
2222
"watch": "run-p watch:ts watch:webpack",
2323
"watch:webpack": "pnpm run --stream --filter @seleniumhq/selenium-ide watch",
@@ -65,7 +65,7 @@
6565
"jest": "^27.5.1",
6666
"jest-cli": "27.5.1",
6767
"npm-run-all": "^4.1.5",
68-
"npm-run-bg": "^1.0.3",
68+
"npm-run-bg": "^1.0.7",
6969
"prettier": "^2.6.0",
7070
"rimraf": "^3.0.2",
7171
"stylelint": "^14.6.0",

packages/selenium-ide/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/selenium-ide",
3-
"version": "4.0.0-alpha.37",
3+
"version": "4.0.0-alpha.38",
44
"private": true,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",
@@ -107,9 +107,9 @@
107107
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1",
108108
"side-code-export": "^4.0.0-alpha.5",
109109
"@seleniumhq/get-driver": "^4.0.0-alpha.1",
110-
"@seleniumhq/side-api": "^4.0.0-alpha.21",
110+
"@seleniumhq/side-api": "^4.0.0-alpha.22",
111111
"@seleniumhq/side-model": "^4.0.0-alpha.3",
112-
"@seleniumhq/side-runtime": "^4.0.0-alpha.22",
112+
"@seleniumhq/side-runtime": "^4.0.0-alpha.23",
113113
"dnd-core": "16.0.1",
114114
"electron-chromedriver": "^18.0.0",
115115
"electron-log": "^4.4.8",

packages/side-api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-api",
3-
"version": "4.0.0-alpha.21",
3+
"version": "4.0.0-alpha.22",
44
"private": false,
55
"description": "Selenium IDE API command shapes and such",
66
"author": "Todd Tarsi <[email protected]>",
@@ -20,7 +20,7 @@
2020
"@seleniumhq/browser-info": "^4.0.0-alpha.1",
2121
"@seleniumhq/get-driver": "^4.0.0-alpha.2",
2222
"@seleniumhq/side-model": "^4.0.0-alpha.3",
23-
"@seleniumhq/side-runtime": "^4.0.0-alpha.22",
23+
"@seleniumhq/side-runtime": "^4.0.0-alpha.23",
2424
"@types/electron": "1.6.10",
2525
"lodash": "^4.17.21"
2626
},

packages/side-code-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"types": "dist/index.d.ts",
2222
"dependencies": {
2323
"@seleniumhq/side-model": "^4.0.0-alpha.3",
24-
"@seleniumhq/side-runtime": "^4.0.0-alpha.22",
24+
"@seleniumhq/side-runtime": "^4.0.0-alpha.23",
2525
"commander": "^9.4.0",
2626
"ua-parser-js": "0.7.28"
2727
},

packages/side-example-suite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-example-suite",
3-
"version": "4.0.0-alpha.1",
3+
"version": "4.0.0-alpha.2",
44
"private": true,
55
"description": "Selenium IDE example suite, with tests, plugin, and export format",
66
"author": "Todd <[email protected]>",
@@ -21,7 +21,7 @@
2121
"@seleniumhq/code-export-python-pytest": "4.0.0-alpha.2"
2222
},
2323
"devDependencies": {
24-
"@seleniumhq/side-runtime": "^4.0.0-alpha.22"
24+
"@seleniumhq/side-runtime": "^4.0.0-alpha.23"
2525
},
2626
"repository": {
2727
"type": "git",

packages/side-runner/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-side-runner",
3-
"version": "4.0.0-alpha.45",
3+
"version": "4.0.0-alpha.46",
44
"private": false,
55
"description": "Run Selenium IDE projects in cli",
66
"repository": "https://github.com/SeleniumHQ/selenium-ide",
@@ -24,7 +24,7 @@
2424
"license": "Apache-2.0",
2525
"dependencies": {
2626
"@seleniumhq/side-model": "^4.0.0-alpha.3",
27-
"@seleniumhq/side-runtime": "^4.0.0-alpha.22",
27+
"@seleniumhq/side-runtime": "^4.0.0-alpha.23",
2828
"commander": "^9.4.0",
2929
"glob": "^7.2.0",
3030
"jest": "^27.5.1",
@@ -33,6 +33,7 @@
3333
"js-beautify": "^1.14.2",
3434
"js-yaml": "^4.1.0",
3535
"lodash": "^4.17.21",
36+
"resolve-bin": "^1.0.1",
3637
"rimraf": "^3.0.2",
3738
"semver": "^7.3.5",
3839
"winston": "^3.6.0"
@@ -43,6 +44,7 @@
4344
"@types/js-beautify": "1.13.3",
4445
"@types/js-yaml": "4.0.5",
4546
"@types/lodash": "^4.14.186",
47+
"@types/resolve-bin": "0.4.1",
4648
"@types/rimraf": "3.0.2",
4749
"@types/semver": "7.3.9",
4850
"@types/winston": "2.4.4"

packages/side-runner/src/bin.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@
1717
// specific language governing permissions and limitations
1818
// under the License.
1919

20+
import { spawn } from 'child_process'
21+
import { Command } from 'commander'
22+
import crypto from 'crypto'
2023
import fs from 'fs'
2124
import merge from 'lodash/fp/merge'
2225
import os from 'os'
2326
import path from 'path'
24-
import crypto from 'crypto'
27+
import resolveBin from 'resolve-bin'
2528
import util from 'util'
26-
import { Command } from 'commander'
2729
import Capabilities from './capabilities'
2830
import Config from './config'
2931
import ParseProxy from './proxy'
3032
import { Configuration, SideRunnerAPI } from './types'
31-
import { spawn } from 'child_process'
32-
33-
const isWindows = os.platform() === 'win32'
3433

3534
const metadata = require('../package.json')
3635

@@ -180,14 +179,7 @@ configuration.debugStartup &&
180179
console.debug('Configuration:', util.inspect(configuration))
181180

182181
// All the stuff that goes into a big wrapped jest command
183-
const jestExecutable = isWindows ? 'jest.cmd' : 'jest'
184-
const jestCommand = path.join(
185-
__dirname,
186-
'..',
187-
'node_modules',
188-
'.bin',
189-
jestExecutable
190-
)
182+
const jest = resolveBin.sync('jest')
191183
const jestArgs = [
192184
'--config=' + path.join(__dirname, '..', 'jest.config.js'),
193185
'--maxConcurrency=' + configuration.maxWorkers,
@@ -209,8 +201,8 @@ const jestEnv = {
209201
}
210202

211203
configuration.debugStartup &&
212-
console.debug('Jest command:', jestCommand, jestArgs, jestEnv)
213-
spawn(jestCommand, jestArgs, {
204+
console.debug('Jest command:', jest, jestArgs, jestEnv)
205+
spawn(jest, jestArgs, {
214206
env: jestEnv,
215207
shell: true,
216208
stdio: 'inherit',

packages/side-runner/src/main.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,7 @@ each(projects).describe(projectTitle, (project: Project) => {
151151
? testExecutor.test.concurrent
152152
: testExecutor.test
153153
testMethod(testTitle, async (test: TestShape) => {
154-
try {
155-
await runners.test(project, test)
156-
} catch (e) {
157-
const err = e as Error
158-
expect(err.message).toBe(undefined)
159-
}
154+
await runners.test(project, test)
160155
})
161156
})
162157
} else {

packages/side-runner/src/run.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ const buildRunners = ({ configuration, logger }: HoistedThings) => {
7676
await playback.cleanup()
7777
await driver.cleanup()
7878
if (failure) {
79-
logger.warn('Completed with failure', failure)
8079
return reject(failure)
8180
} else {
8281
return resolve(null)
@@ -99,8 +98,15 @@ const buildRunners = ({ configuration, logger }: HoistedThings) => {
9998
state === 'finished' ? 'Success' : 'Failure'
10099
}`
101100
)
102-
onComplete(state !== 'finished')
101+
if (state !== 'finished') {
102+
return onComplete(
103+
playback['state'].lastSentCommandState?.error ||
104+
new Error('Unknown error')
105+
)
106+
}
107+
return onComplete(null)
103108
}
109+
return
104110
}
105111
)
106112
EE.addListener(
@@ -125,7 +131,6 @@ const buildRunners = ({ configuration, logger }: HoistedThings) => {
125131
startingCommandIndex: 0,
126132
})
127133
} catch (e) {
128-
console.error(e)
129134
await playback.cleanup()
130135
return reject(e)
131136
}

packages/side-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-runtime",
3-
"version": "4.0.0-alpha.22",
3+
"version": "4.0.0-alpha.23",
44
"private": false,
55
"description": "Selenium IDE playback and execution",
66
"author": "Tomer <[email protected]>",

0 commit comments

Comments
 (0)