Skip to content

Commit 9b7d525

Browse files
committed
feat: add --junit to selenium-side-runner to export JUnit XML
1 parent f63add8 commit 9b7d525

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/selenium-side-runner/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"global-npm": "^0.3.0",
3535
"jest-cli": "24.1.0",
3636
"jest-environment-selenium": "2.1.0",
37+
"jest-junit": "^6.3.0",
3738
"js-beautify": "^1.7.5",
3839
"js-yaml": "^3.10.0",
3940
"rimraf": "^2.6.2",

packages/selenium-side-runner/src/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ program
7272
'--output-directory [directory]',
7373
'Write test results to files, results written in JSON'
7474
)
75+
.option(
76+
'--junit',
77+
'Write test results to files, results written in JUnit XML format'
78+
)
7579
.option(
7680
'--force',
7781
"Forcibly run the project, regardless of project's version"
@@ -228,7 +232,18 @@ function runProject(project) {
228232
],
229233
testEnvironment: 'jest-environment-selenium',
230234
testEnvironmentOptions: configuration,
235+
...(program.junit ? { reporters: ['default', 'jest-junit'] } : {}),
231236
},
237+
...(program.junit && program.outputDirectory
238+
? {
239+
'jest-junit': {
240+
outputDirectory: path.isAbsolute(program.outputDirectory)
241+
? program.outputDirectory
242+
: '../' + program.outputDirectory,
243+
outputName: `${project.name}.xml`,
244+
},
245+
}
246+
: {}),
232247
dependencies: project.dependencies || {},
233248
},
234249
null,
@@ -319,7 +334,7 @@ function runJest(project) {
319334
]
320335
.concat(program.maxWorkers ? ['-w', program.maxWorkers] : [])
321336
.concat(
322-
program.outputDirectory
337+
program.outputDirectory && !program.junit
323338
? [
324339
'--json',
325340
'--outputFile',

0 commit comments

Comments
 (0)