Skip to content

Commit

Permalink
Merge branch 'master' into munter/transpilation
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Jul 1, 2020
2 parents 871f958 + e30ae28 commit bf3662e
Show file tree
Hide file tree
Showing 30 changed files with 373 additions and 431 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/nightly-site-deploy.yml
@@ -0,0 +1,16 @@
# Deploy `mochajs.org` branch nightly by hitting a netlify build URL.
# This updates the list of supporters

name: Nightly mochajs.org Deploy
on:
schedule:
- cron: '0 0 * * *'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Webhook Action
uses: joelwmale/webhook-action@1.0.0
env:
data: ''
WEBHOOK_URL: ${{ secrets.NETLIFY_NIGHTLY_DEPLOY_URL }}
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -39,8 +39,6 @@ jobs:
- script: COVERAGE=1 npm start test.node
after_success: npm start coveralls
name: 'Latest Node.js (with coverage)'
- script: MOCHA_PARALLEL=0 npm start test.node.unit
name: 'Latest Node.js (unit tests in serial mode)'

- &node
script: npm start test.node
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -14,7 +14,7 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt

## :boom: Breaking Changes

- [#4164](https://github.com/mochajs/mocha/issues/4164): **Mocha v8.0.0 now requires Node.js v10.0.0 or newer.** Mocha no longer supports the Node.js v8.x line ("Carbon"), which entered End-of-Life at the end of 2019 ([**@UlisesGascon**](https://github.com/UlisesGascon))
- [#4164](https://github.com/mochajs/mocha/issues/4164): **Mocha v8.0.0 now requires Node.js v10.12.0 or newer.** Mocha no longer supports the Node.js v8.x line ("Carbon"), which entered End-of-Life at the end of 2019 ([**@UlisesGascon**](https://github.com/UlisesGascon))

- [#4175](https://github.com/mochajs/mocha/issues/4175): Having been deprecated with a warning since v7.0.0, **`mocha.opts` is no longer supported** ([**@juergba**](https://github.com/juergba))

Expand All @@ -35,6 +35,7 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt
- [#4223](https://github.com/mochajs/mocha/issues/4223): The context object's `skip()` (`this.skip()`) in a "before all" (`before()`) hook will no longer execute subsequent sibling hooks, in addition to hooks in child suites ([**@juergba**](https://github.com/juergba))

- [#4178](https://github.com/mochajs/mocha/issues/4178): Remove previously soft-deprecated APIs ([**@wnghdcjfe**](https://github.com/wnghdcjfe)):

- `Mocha.prototype.ignoreLeaks()`
- `Mocha.prototype.useColors()`
- `Mocha.prototype.useInlineDiffs()`
Expand All @@ -54,6 +55,10 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt

- [#4246](https://github.com/mochajs/mocha/issues/4246): Add documentation for parallel mode and Root Hook plugins ([**@boneskull**](https://github.com/boneskull))

## :nut_and_bolt: Other

- [#4200](https://github.com/mochajs/mocha/issues/4200): Drop mkdirp and replace it with fs.mkdirSync ([**@HyunSangHan**](https://github.com/HyunSangHan))

## :bug: Fixes

(All bug fixes in Mocha v8.0.0 are also breaking changes, and are listed above)
Expand Down
2 changes: 2 additions & 0 deletions docs/_data/blacklist.json → docs/_data/blocklist.json
Expand Up @@ -17,5 +17,7 @@
"trust-my-paper",
"seowebsitetraffic-net",
"pfannen-test",
"casinobosscanada-com",
"suominettikasinot24",
"mochajs"
]
14 changes: 14 additions & 0 deletions docs/index.md
Expand Up @@ -37,6 +37,7 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in
- [config file support](#-config-path)
- [node debugger support](#-inspect-inspect-brk-inspect)
- [node native ES modules support](#nodejs-native-esm-support)
- [source-map support](#-enable-source-maps)
- [detects multiple calls to `done()`](#detects-multiple-calls-to-done)
- [use any assertion library you want](#assertions)
- [extensible reporting, bundled with 9+ reporters](#reporters)
Expand Down Expand Up @@ -1142,6 +1143,19 @@ These flags vary depending on your version of Node.js.

`node` flags can be defined in Mocha's [configuration](#configuring-mocha-nodejs).

### `--enable-source-maps`

> _New in Node.js v12.12.0_
If the [`--enable-source-maps`](https://nodejs.org/dist/latest-v12.x/docs/api/cli.html#cli_enable_source_maps) flag
is passed to mocha, source maps will be collected and used to provide accurate stack traces for transpiled code:

```bash
Error: cool
at Object.<anonymous> (/Users/fake-user/bigco/nodejs-tasks/build/src/index.js:27:7)
-> /Users/fake-user/bigco/nodejs-tasks/src/index.ts:24:7
```

### About V8 Flags

Prepend `--v8-` to any flag listed in the output of `node --v8-options` (excluding `--v8-options` itself) to use it.
Expand Down
12 changes: 7 additions & 5 deletions lib/reporters/base.js
Expand Up @@ -78,7 +78,9 @@ exports.colors = {
light: 90,
'diff gutter': 90,
'diff added': 32,
'diff removed': 31
'diff removed': 31,
'diff added inline': '30;42',
'diff removed inline': '30;41'
};

/**
Expand Down Expand Up @@ -417,9 +419,9 @@ function inlineDiff(actual, expected) {
// legend
msg =
'\n' +
color('diff removed', 'actual') +
color('diff removed inline', 'actual') +
' ' +
color('diff added', 'expected') +
color('diff added inline', 'expected') +
'\n\n' +
msg +
'\n';
Expand Down Expand Up @@ -485,10 +487,10 @@ function errorDiff(actual, expected) {
.diffWordsWithSpace(actual, expected)
.map(function(str) {
if (str.added) {
return colorLines('diff added', str.value);
return colorLines('diff added inline', str.value);
}
if (str.removed) {
return colorLines('diff removed', str.value);
return colorLines('diff removed inline', str.value);
}
return str.value;
})
Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -67,7 +67,7 @@
"ms": "2.1.2",
"object.assign": "4.1.0",
"promise.allsettled": "1.0.2",
"serialize-javascript": "3.0.0",
"serialize-javascript": "3.1.0",
"strip-json-comments": "3.0.1",
"supports-color": "7.1.0",
"which": "2.0.2",
Expand Down
18 changes: 8 additions & 10 deletions test/node-unit/buffered-runner.spec.js
Expand Up @@ -13,11 +13,10 @@ const BUFFERED_RUNNER_PATH = require.resolve(
);
const Suite = require('../../lib/suite');
const Runner = require('../../lib/runner');
const {createSandbox} = require('sinon');
const sinon = require('sinon');

describe('buffered-runner', function() {
describe('BufferedRunner', function() {
let sandbox;
let run;
let BufferedWorkerPool;
let terminate;
Expand All @@ -27,27 +26,26 @@ describe('buffered-runner', function() {
let cpuCount;

beforeEach(function() {
sandbox = createSandbox();
cpuCount = 1;
suite = new Suite('a root suite', {}, true);
warn = sandbox.stub();
warn = sinon.stub();

// tests will want to further define the behavior of these.
run = sandbox.stub();
terminate = sandbox.stub();
run = sinon.stub();
terminate = sinon.stub();
BufferedWorkerPool = {
create: sandbox.stub().returns({
create: sinon.stub().returns({
run,
terminate,
stats: sandbox.stub().returns({})
stats: sinon.stub().returns({})
})
};
BufferedRunner = rewiremock.proxy(BUFFERED_RUNNER_PATH, r => ({
'../../lib/nodejs/buffered-worker-pool': {
BufferedWorkerPool
},
os: {
cpus: sandbox.stub().callsFake(() => new Array(cpuCount))
cpus: sinon.stub().callsFake(() => new Array(cpuCount))
},
'../../lib/utils': r.with({warn}).callThrough()
}));
Expand Down Expand Up @@ -157,7 +155,7 @@ describe('buffered-runner', function() {

it('should delegate to Runner#uncaught', function(done) {
const options = {};
sandbox.spy(runner, 'uncaught');
sinon.spy(runner, 'uncaught');
const err = new Error('whoops');
run.withArgs('some-file.js', options).rejects(new Error('whoops'));
run.withArgs('some-other-file.js', options).resolves({
Expand Down
18 changes: 8 additions & 10 deletions test/node-unit/buffered-worker-pool.spec.js
@@ -1,36 +1,34 @@
'use strict';

const rewiremock = require('rewiremock/node');
const {createSandbox} = require('sinon');
const sinon = require('sinon');

describe('class BufferedWorkerPool', function() {
let BufferedWorkerPool;
let sandbox;
let pool;
let stats;
let serializeJavascript;
let serializer;
let result;

beforeEach(function() {
sandbox = createSandbox();
stats = {totalWorkers: 10, busyWorkers: 8, idleWorkers: 2, pendingTasks: 3};
result = {failures: 0, events: []};
pool = {
terminate: sandbox.stub().resolves(),
exec: sandbox.stub().resolves(result),
stats: sandbox.stub().returns(stats)
terminate: sinon.stub().resolves(),
exec: sinon.stub().resolves(result),
stats: sinon.stub().returns(stats)
};
serializer = {
deserialize: sandbox.stub()
deserialize: sinon.stub()
};

serializeJavascript = sandbox.spy(require('serialize-javascript'));
serializeJavascript = sinon.spy(require('serialize-javascript'));
BufferedWorkerPool = rewiremock.proxy(
require.resolve('../../lib/nodejs/buffered-worker-pool'),
{
workerpool: {
pool: sandbox.stub().returns(pool),
pool: sinon.stub().returns(pool),
cpus: 8
},
'../../lib/nodejs/serializer': serializer,
Expand All @@ -43,7 +41,7 @@ describe('class BufferedWorkerPool', function() {
});

afterEach(function() {
sandbox.restore();
sinon.restore();
});

describe('static method', function() {
Expand Down
21 changes: 8 additions & 13 deletions test/node-unit/cli/config.spec.js
@@ -1,18 +1,13 @@
'use strict';

const {createSandbox} = require('sinon');
const sinon = require('sinon');
const rewiremock = require('rewiremock/node');

describe('cli/config', function() {
let sandbox;
const phonyConfigObject = {ok: true};

beforeEach(function() {
sandbox = createSandbox();
});

afterEach(function() {
sandbox.restore();
sinon.restore();
});

describe('loadConfig()', function() {
Expand All @@ -29,9 +24,9 @@ describe('cli/config', function() {

describe('when parsing succeeds', function() {
beforeEach(function() {
sandbox.stub(parsers, 'yaml').returns(phonyConfigObject);
sandbox.stub(parsers, 'json').returns(phonyConfigObject);
sandbox.stub(parsers, 'js').returns(phonyConfigObject);
sinon.stub(parsers, 'yaml').returns(phonyConfigObject);
sinon.stub(parsers, 'json').returns(phonyConfigObject);
sinon.stub(parsers, 'js').returns(phonyConfigObject);
});

describe('when supplied a filepath with ".yaml" extension', function() {
Expand Down Expand Up @@ -103,7 +98,7 @@ describe('cli/config', function() {

describe('when supplied a filepath with unsupported extension', function() {
beforeEach(function() {
sandbox.stub(parsers, 'json').returns(phonyConfigObject);
sinon.stub(parsers, 'json').returns(phonyConfigObject);
});

it('should use the JSON parser', function() {
Expand All @@ -114,7 +109,7 @@ describe('cli/config', function() {

describe('when config file parsing fails', function() {
beforeEach(function() {
sandbox.stub(parsers, 'yaml').throws();
sinon.stub(parsers, 'yaml').throws();
});

it('should throw', function() {
Expand All @@ -129,7 +124,7 @@ describe('cli/config', function() {
let CONFIG_FILES;

beforeEach(function() {
findup = {sync: sandbox.stub().returns('/some/path/.mocharc.js')};
findup = {sync: sinon.stub().returns('/some/path/.mocharc.js')};
const config = rewiremock.proxy(
require.resolve('../../../lib/cli/config'),
r => ({
Expand Down

0 comments on commit bf3662e

Please sign in to comment.