Skip to content

Commit

Permalink
chore: fix mocha junit reporter when running mocha <6
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel committed May 7, 2024
1 parent f14a11a commit 39ab043
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 0 additions & 4 deletions cli/test/lib/tasks/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ describe('lib/tasks/download', function () {
})

context('architecture detection', () => {
beforeEach(() => {
sinon.stub(os, 'arch')
})

context('Apple Silicon/M1', () => {
function nockDarwinArm64 () {
return nock('https://download.cypress.io')
Expand Down
1 change: 1 addition & 0 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('util', () => {
context('.isBrokenGtkDisplay', () => {
it('detects only GTK message', () => {
os.platform.returns('linux')
os.arch.returns('x64')
const text = '[some noise here] Gtk: cannot open display: 99'

expect(util.isBrokenGtkDisplay(text)).to.be.true
Expand Down
3 changes: 3 additions & 0 deletions cli/test/spec_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ sinon.stub = function (obj, method) {

beforeEach(function () {
sinon.stub(os, 'platform')
sinon.stub(os, 'arch')
sinon.stub(os, 'release')
sinon.stub(util, 'getOsVersionAsync').resolves('Foo-OsVersion')

os.arch.returns('x64')
})

afterEach(function () {
Expand Down
13 changes: 13 additions & 0 deletions patches/mocha-junit-reporter+2.2.0.dev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/mocha-junit-reporter/index.js b/node_modules/mocha-junit-reporter/index.js
index fbbed2e..de27092 100644
--- a/node_modules/mocha-junit-reporter/index.js
+++ b/node_modules/mocha-junit-reporter/index.js
@@ -366,7 +366,7 @@ MochaJUnitReporter.prototype.getTestcaseData = function(test, err) {
message = '';
}
var failureMessage = err.stack || message;
- if (!Base.hideDiff && err.expected !== undefined) {
+ if (!Base.hideDiff && err.expected !== undefined && mocha6plus) {
var oldUseColors = Base.useColors;
Base.useColors = false;
failureMessage += "\n" + Base.generateDiff(err.actual, err.expected);

0 comments on commit 39ab043

Please sign in to comment.