Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build UMD bundle and polyfill language features #4366

Merged
merged 12 commits into from Jul 28, 2020
Merged

Conversation

boneskull
Copy link
Member

  • remove old ESlint rule to disallow Object.assign
  • consume Rollup config's output prop in karma-rollup-plugin
  • simplify rollup.config.js output prop
  • fix invalid script tag src attrib in lib/browser/template.html (& reformat)

@boneskull boneskull added area: browser browser-specific type: chore generally involving deps, tooling, configuration, etc. semver-patch implementation requires increase of "patch" version number; "bug fixes" labels Jul 6, 2020
@boneskull boneskull requested a review from Munter July 6, 2020 20:14
@boneskull boneskull self-assigned this Jul 6, 2020
@boneskull
Copy link
Member Author

@Munter I found that when using umd output while window.mocha.setup did not exist, window.mocha.mocha.setup did exist.

using object spread syntax module.exports = {...global, ...mocha} causes Rollup (?) to generate a ES module then complains about having default and named exports. I have no idea why.

I think even the global.mocha = mocha and global.Mocha = Mocha lines are probably unnecessary, since the UMD bundle will stuff module.exports into global.

@boneskull
Copy link
Member Author

update: the global.mocha and global.Mocha stuff is necessary. I guess I really don't get it. but whatever.

@coveralls
Copy link

coveralls commented Jul 6, 2020

Coverage Status

Coverage remained the same at 93.932% when pulling 2cf235b on boneskull/rollup-umd into 02bdb6b on master.

@boneskull
Copy link
Member Author

looks like I jumped the gun a little there. it worked for a test file anyway (as created by mocha init)

@boneskull
Copy link
Member Author

alright, tweaked the exports. it's now

mocha.Mocha = Mocha;
mocha.mocha = mocha;
module.exports = Object.assign(mocha, global);

@boneskull
Copy link
Member Author

AMD bundle seems to "work" per manual test, but the failing test isn't of much value.

@boneskull
Copy link
Member Author

added a proper test for AMD; closes #2426

karma.conf.js Outdated
@@ -134,19 +135,38 @@ module.exports = config => {
{pattern: 'test/browser-specific/esm.spec.mjs', type: 'module'}
];
break;
case 'requirejs':
cfg.plugins.push('karma-requirejs');
cfg.frameworks.unshift('requirejs');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does order matter? I have no idea

karma.conf.js Outdated
require.resolve('./test/browser-specific/setup')
);
if (MOCHA_TEST !== 'requirejs') {
cfg.files.unshift(
Copy link
Member Author

@boneskull boneskull Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unexpected is broken when used with AMD. something about mismatched defines

@boneskull
Copy link
Member Author

@Munter something is not pulling in the target browser list here

@boneskull
Copy link
Member Author

wow, it works!

@@ -496,11 +496,11 @@ describe('lib/utils', function() {
if (typeof global.Symbol === 'function') {
it('should handle Symbol', function() {
var symbol = Symbol('value');
expect(stringify(symbol), 'to be', 'Symbol(value)');
expect(stringify(symbol), 'to match', /^Symbol\(value\)/);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core-js adds weird characters to the Symbol string representation in IE11. 🤷‍♂️

karma.conf.js Outdated
@@ -17,7 +17,7 @@ const browserPlatformPairs = {
};

module.exports = config => {
let bundleDirpath;
let bundleDirpath = path.join(baseBundleDirpath, hostname);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, this would have been added to the cfg object before it was defined. now, we only add it if creating the directory succeeds.

maybe we should ignore a mkdir failure and just use the tmp dir... I don't want to run the build again 😜

<script>
mocha.setup('bdd');
</script>
<script src="tests.spec.js"></script>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was wrong.

we should run linkcheck on this thing.

boneskull added a commit that referenced this pull request Jul 8, 2020
- 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
@boneskull boneskull changed the title build a UMD bundle instead of IIFE build UMD bundle and polyfill language features Jul 13, 2020
@@ -49,7 +49,7 @@ jobs:
node_js: '10'
name: 'Node.js v10'

- script: npm start test.bundle test.browser
- script: npm start test.browser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test.bundle becomes test.browser.requirejs

boneskull added a commit that referenced this pull request Jul 14, 2020
- 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
boneskull added a commit that referenced this pull request Jul 16, 2020
- 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
boneskull added a commit that referenced this pull request Jul 17, 2020
- 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
- remove old ESlint rule to disallow `Object.assign`
- consume Rollup config's `output` prop in `karma-rollup-plugin`
- simplify `rollup.config.js` `output` prop
- fix invalid `script` tag `src` attrib in `lib/browser/template.html` (& reformat)
- fix broken bundle output path
- remove the old `bundle/amd.spec.js` test
- _actually_ fix bundle output file path
- fix a typo in karma rollup plugin
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
Signed-off-by: Christopher Hiller <boneskull@boneskull.com>
- `unexpected`, `unexpected-eventemitter`, and `unexpected-sinon` are now external (not bundled) and loaded via their globals
- modified `test/browser-specific/setup.js` to use `require()` since we can do that now
- bundle now has an inline source map since I couldn't figure out any other way to load it
- removed duplication of work in the karma plugin; no call to `bundle.generate()` is needed. furthermore the `code` prop did not include the inline source maps. so we just write the file and read the result. could probably avoid reading the file by manually stitching the `code` and `map` props together, but I'm unsure how
- loads `mocha.js.map`
@juergba
Copy link
Member

juergba commented Jul 24, 2020

@boneskull I can't review this PR explained by my complete incompetence in this matter, sorry.
This rollup thing is a wild fusion of bundling, transpiling and karma/testing without clear distinction. I don't understand neither why we need an additional module definition UMD. What definition have we used before with browserify?

@boneskull
Copy link
Member Author

our browserify bundle is not quite UMD, but it 1. defines globals and 2. enables bundling of the bundle. it does not supply a AMD-compatible bundle, but it also does not inhibit AMD bundles.

The rationale for this PR, then, is:

  1. the iife output of Rollup does not seem to allow number 2, which is going to break consumers; we need the umd output style
  2. after Rollup and babel in build pipeline #4293 landed, we're able to use some modern syntax everywhere, but not all modern syntax everywhere. the changes to our babel config in this PR make it possible to use, e.g., async/await anywhere in our sources and tests (because Node.js v10, our minimum-supported version of Node.js, allows this). We could not use the native Promise object, either--but now we can, because of the polyfilling core-js does.
  3. the umd output style of Rollup does provide an AMD bundle, which made the previous test case (test.bundle) fail. I had to write some new tests to assert compatibility (and learn some RequireJS...ugh)

with this PR--for whatever reason--the resulting bundle size is about 20Kb less.

@boneskull
Copy link
Member Author

that said, this has been sitting for like 3 weeks, and I need to move forward with it to get global fixtures in.

@boneskull boneskull merged commit ad03d29 into master Jul 28, 2020
@boneskull boneskull deleted the boneskull/rollup-umd branch July 28, 2020 21:11
boneskull added a commit that referenced this pull request Jul 28, 2020
- 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)
@boneskull boneskull added this to the next milestone Jul 29, 2020
boneskull added a commit that referenced this pull request Jul 30, 2020
- 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)
@outsideris outsideris mentioned this pull request Aug 8, 2020
2 tasks
boneskull added a commit that referenced this pull request Aug 14, 2020
- 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)
boneskull added a commit that referenced this pull request Aug 18, 2020
- 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)
boneskull added a commit that referenced this pull request Aug 18, 2020
- 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)
boneskull added a commit that referenced this pull request Aug 25, 2020
- 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific semver-patch implementation requires increase of "patch" version number; "bug fixes" type: chore generally involving deps, tooling, configuration, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants