From de3f453cfde642f79a0fbbef5418a12187797196 Mon Sep 17 00:00:00 2001 From: "Peter P. Gengler" Date: Sat, 17 Jul 2021 13:46:00 -0600 Subject: [PATCH 1/4] Fix mocha option from colors -> color --- client/shim.js | 2 +- index.js | 2 +- lib/cli.js | 4 ++-- test/api.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/shim.js b/client/shim.js index ad424ca..cd28380 100644 --- a/client/shim.js +++ b/client/shim.js @@ -12,7 +12,7 @@ mochaOptions = mochaOptions || { ui: 'bdd', reporter: 'spec', - colors: true + color: true }; mocha.setup(mochaOptions); diff --git a/index.js b/index.js index 29ef9fa..a0c3a10 100644 --- a/index.js +++ b/index.js @@ -30,7 +30,7 @@ class MochaChrome { mocha: { reporter: 'spec', ui: 'bdd', - colors: true + color: true } }, options diff --git a/lib/cli.js b/lib/cli.js index a468e20..3327251 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -68,9 +68,9 @@ if (!/^(file|http(s?)):\/\//.test(file)) { url = `file://${fs.realpathSync(file)}`; } -const colors = !!flags.colors; +const color = !!flags.color; const reporter = flags.reporter || 'spec'; -const mocha = Object.assign(JSON.parse(flags.mocha || '{}'), { colors, reporter }); +const mocha = Object.assign(JSON.parse(flags.mocha || '{}'), { color, reporter }); const chromeFlags = JSON.parse(flags.chromeFlags || '[]'); const { chromeLauncher = {}, diff --git a/test/api.js b/test/api.js index 76db186..b1370ee 100644 --- a/test/api.js +++ b/test/api.js @@ -14,7 +14,7 @@ function test(options) { options = deepAssign( (options = { url, - mocha: { colors: false }, + mocha: { color: false }, ignoreConsole: true, ignoreExceptions: true, ignoreResourceErrors: true From a538162e4a89f7e7080c586c307a64d35f959482 Mon Sep 17 00:00:00 2001 From: "Peter P. Gengler" Date: Sat, 17 Jul 2021 13:58:23 -0600 Subject: [PATCH 2/4] Add peerDependency for mocha >= 7.0.0 --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 01b2b1d..00dda62 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,9 @@ "LICENSE", "README.md" ], + "peerDependencies": { + "mocha": ">= 7.0.0" + }, "dependencies": { "chalk": "^2.0.1", "chrome-launcher": "^0.13.4", From b8ee9abf51016080ce0f75fd348f17d7e1b1b2bf Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Sun, 26 Sep 2021 00:56:34 +0900 Subject: [PATCH 3/4] Publish fork as new NPM package version. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 00dda62..3f4be29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "mocha-chrome", - "version": "2.2.0", + "name": "digabi-mocha-chrome", + "version": "2.3.0", "description": "☕ Run Mocha tests using headless Google Chrome", "license": "MIT", "repository": "shellscape/mocha-chrome", From 3d50fc157a056672484b091ee1683202cd4ec5aa Mon Sep 17 00:00:00 2001 From: Sami Saves Date: Thu, 2 Jun 2022 16:04:09 +0300 Subject: [PATCH 4/4] Add timeout to emitting ended event We need the delay here because the TAP reporter calls mochas runner end event and writes final lines there and at the same time we use the same runner end event to emit our 'ended' event which starts closing the browser. This means that the browser usually closes before the TAP reporter has written all of its last lines --- client/shim.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/shim.js b/client/shim.js index cd28380..18a1177 100644 --- a/client/shim.js +++ b/client/shim.js @@ -55,10 +55,14 @@ m.runner = origRun.apply(mocha, arguments); if (m.runner.stats && m.runner.stats.end) { - window._eventbus.emit('ended', m.runner.stats); + setTimeout(()=>{ + window._eventbus.emit('ended', m.runner.stats); + }, 2000) } else { m.runner.on('end', () => { - window._eventbus.emit('ended', m.runner.stats); + setTimeout(()=>{ + window._eventbus.emit('ended', m.runner.stats); + }, 2000) }); } return m.runner;