Skip to content

Commit

Permalink
re-enable junit reporter, update mocha result verification to be more…
Browse files Browse the repository at this point in the history
… lenient about the order of xml fields
  • Loading branch information
cacieprins committed Jan 13, 2025
1 parent 03c0865 commit 6d580b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/driver/vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export default defineConfig({
include: ['test/unit/**/*.spec.ts'],
environment: 'jsdom',
exclude: ['**/__fixtures__/**/*'],
reporters: [
'default',
['junit', { suiteName: 'Driver Unit Tests', outputFile: '/tmp/cypress/junit/driver-test-results.xml' }],
],
},
})
6 changes: 5 additions & 1 deletion scripts/verify-mocha-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ const la = require('lazy-ass')
const path = require('path')
const { readCircleEnv } = require('./circle-env')

// mocha regex
const RESULT_REGEX = /<testsuites name="([^"]+)" time="([^"]+)" tests="([^"]+)" failures="([^"]+)"(?: skipped="([^"]+)"|)>/
// vitest regex
const VRESULT_REGEX = /<testsuites name="([^"]+)" tests="([^"]+)" failures="([^"]+)" errors="([^"]+)" time="([^"]+)"(?: skipped="([^"]+)"|)>/

const REPORTS_PATH = '/tmp/cypress/junit'

const expectedResultCount = Number(process.argv[process.argv.length - 1])

const parseResult = (xml) => {
const [name, time, tests, failures, skipped] = RESULT_REGEX.exec(xml).slice(1)
const [name, time, tests, failures, skipped] = (RESULT_REGEX.exec(xml) ?? VRESULT_REGEX.exec(xml)).slice(1)

return {
name, time, tests: Number(tests), failures: Number(failures), skipped: Number(skipped || 0),
Expand Down

0 comments on commit 6d580b0

Please sign in to comment.