Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial implementation of global setup/teardown
- adds a generic "plugin loader" which handles root hooks, global setup/teardown, future - renamed `validatePlugin` to `validateLegacyPlugin`. reporters/interfaces should eventually be refactored to use this plugin system - should maybe decouple plugins from the `Mocha` prototype - new events emitted by `Runner` for global setup/teardown - need to add unit tests, need to support parallel mode upgrade eslint-config-semistandard more implementation, tests added more tests, implementation. needs #4366 for browser compat - removed dead code in `lib/cli/run-helpers.js` - be sure not to send certain options to the worker processes - fix root hook bug in worker - send global fixtures to `Runner` constructor - removed debugs - **add `Process.unhandledRejection` listeners** which might be bad - fix some tests while I'm fixing tests reorganize plugin fixtures add "to contain once" mocha result output assertion (to ensure some output is not duplicated) add runGlobalSetup, runGlobalTeardown to Mocha revert changes to Runner `Mocha` will handle global fixtures no events will be emitted remove test/integration/options/require.spec.js which is now in test/integration/plugins/ revert change to ParallelBufferedRunner which invoked global fixtures pull helper code out of test/integration/options/watch.spec.js into integration test helpers - because it's nice to be able to test watching elsewhere - also renamed `runMochaWatch` to `runMochaWatchJSON` and provide `runMochaWatch` for plain output move tests from test/integration/options/require.spec.js into test/integration/plugins/root-hooks.spec.js Mocha#run now runs global fixtures; add watch mode support - add `enableGlobalSetup()` and `enableGlobalTeardown()` methods on `Mocha` - update `globalSetup()` and `globalTeardown()` methods - watch mode runs global teardown upon `SIGINT`. is that right? add command prop to runMochaJSON return value if a fixture run with `runMochaJSON()` fails, the return value now contains a `command` prop (like the result of `runMocha()`) for easier debugging remove unused garbage from RUnner fix bug where mocha would never exit with a non-zero code - I think this is understandable, because `done()` is weirdly _not_ an error-first callback - remove try/catch guards around fixtures and let `process` uncaught/unhandled listeners deal w/ it - also fix `unit/mocha.spec.js` test update package-lock.json move plugin.spec.js into node tests for now remove unused 'watchify', add 'touch' Signed-off-by: Christopher Hiller <boneskull@boneskull.com> remove noisy debugs in Runner fix flaky test in test/unit/mocha.spec.js rename assertion types - `JSONRunResult` -> `JSONResult` - `RawRunResult` -> `SummarizedResult` - `RawResult` remains the same - tweak identification functions integration test helper improvements - better organization - renamed stuff for consistency - `runMochaWatch` -> `runMochaWatchAsync` - `splitRegExp` -> `SPLIT_DOT_REPORTER_REGEXP` - rename parameters, add and fix docstrings - modernize some of it - add various typedefs to align with assertion types - remove `invokeSubMocha` as it is no longer needed now that `mocha` will not fork a process if no `node` options are provided - add special case for _forking_ mocha on win32 in watch mode, as that's the only way we can cleanup cleanly (parallel runs will need this treatment too, but I think it demands a more generalized solution) - fix potential bug in `resolveFixturePath()` - in `runMochaWatchAsync`, add `sleepMs` option; defaults to 2s - extract `createTempDir()` from various test files and expose on helper - prefer `rimraf` over `fs-extra.remove` since the former will retry when dir is locked on win32 - expose `touchFile()` on helper; do not use wonky handrolled touching algorithms and use [touch](https://npm.im/touch) instead - update tests to use new helpers and renamed helpers watch improvements and refactors - print "waiting" msg to stderr (_should_ be ok) - add "cleaning up" message upon ctrl-c - remove needless `afterRun` option from various places - only run teardown fixtures if they exist - add win32 fix for testing - add `Mocha#hasGlobalSetupFixtures()` and `Mocha#hasGlobalTeardownFixtures()` more tests Signed-off-by: Christopher Hiller <boneskull@boneskull.com> upgrade rewiremock Signed-off-by: Christopher Hiller <boneskull@boneskull.com> rename lib/plugin => lib/plugin-loader - rename `createInvalidPluginError` => `createInvalidLegacyPluginError` and soft-deprecate - add `createInvalidPluginDefinitionError` and `createInvalidPluginImplementationError` w/ constants; use them - move some typedefs into `lib/mocha.js` as they are referenced via public aforementioned error factories - remove TS docstrings - better coverage - move `plugin-loader` test back into `test/unit` (removed rewiremock from it)
- Loading branch information