Skip to content

Commit 4c71f2e

Browse files
committed
mocha import fix
1 parent 02ae24b commit 4c71f2e

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

bin/testObservability/helper/helper.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,22 @@ const getCypressCommandEventListener = () => {
377377

378378
const setEventListeners = () => {
379379
try {
380+
const cypressCommandEventListener = getCypressCommandEventListener();
380381
glob(process.cwd() + '/cypress/support/*.js', {}, (err, files) => {
381382
if(err) return exports.debug('EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files');
382383
files.forEach(file => {
383384
try {
384385
if(!file.includes('commands.js')) {
385386
const defaultFileContent = fs.readFileSync(file, {encoding: 'utf-8'});
386-
387-
let newFileContent = defaultFileContent +
387+
388+
if(!defaultFileContent.includes(cypressCommandEventListener)) {
389+
let newFileContent = defaultFileContent +
388390
'\n' +
389-
getCypressCommandEventListener() +
391+
cypressCommandEventListener +
390392
'\n'
391-
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
392-
supportFileContentMap[file] = defaultFileContent;
393+
fs.writeFileSync(file, newFileContent, {encoding: 'utf-8'});
394+
supportFileContentMap[file] = defaultFileContent;
395+
}
393396
}
394397
} catch(e) {
395398
exports.debug(`Unable to modify file contents for ${file} to set event listeners with error ${e}`, true, e);

bin/testObservability/reporter/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ const util = require('util');
44
const fs = require('fs');
55
const path = require('path');
66
const { requireModule } = require('../helper/helper');
7-
const Base = requireModule('mocha/lib/reporters/base.js', true),
8-
utils = requireModule('mocha/lib/utils.js', true);
7+
const Base = requireModule('mocha/lib/reporters/base.js'),
8+
utils = requireModule('mocha/lib/utils.js');
99
const color = Base.color;
10-
const Mocha = requireModule('mocha', true);
10+
const Mocha = requireModule('mocha');
1111
// const Runnable = requireModule('mocha/lib/runnable');
12-
const Runnable = require('mocha/lib/runnable', true); // need to handle as this isn't present in older mocha versions
12+
const Runnable = require('mocha/lib/runnable'); // need to handle as this isn't present in older mocha versions
1313
const { v4: uuidv4 } = require('uuid');
1414

1515
const { IPC_EVENTS } = require('../helper/constants');

0 commit comments

Comments
 (0)