Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Await before mocha.run and support mocha.requireHooks #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

loynoir
Copy link

@loynoir loynoir commented Oct 28, 2021

Related issues

#243

Changes

  1. Await all script type="module" before mocha.run. If await failed, add a unit test, and throw error within.
  2. Remove lib/adapter.js from gitignore, so can use npm install <repo>.
  3. mocha.requireHooks now supported, load thru {type:"import", value:"/base/my/path/to/mochaHooks.mjs"}
  4. Add unit test to verify mocha.requireHooks.beforeAll works.
  5. Using mocha.requireHooks.afterAll to verify mocha.run run after all slow ESM modules.
  6. devDependencies updated, to support requireHooks and type = 'module'

Uncaught TypeError: this[opt] is not a function

Update mocha from 3.5.3 to 9.1.3, to support rootHooks

Uncaught SyntaxError: Unexpected token 'export'

Update karma from 1.7.1 to 6.3.6, to support files.type = 'module'

WARN [karma-server]: Passing raw CLI options to `new Server(config, done)` is deprecated. Use `parseConfig(c
onfigFilePath, cliOptions, {promiseConfig: true, throwErrors: true})` to prepare a processed `Config` instance and pass that as the 
`config` argument instead.

Update grunt-karma from 2.0.0 to 4.0.2, to get rid of warning.

  1. README.md updated for requireHooks

TODO

  1. import(), reported SyntaxError by low version eslint
  2. Remove importSync() and importSyncFallback() when mocha accept serializable .requireHooks, or accept import() as .requireHooks input.

@scottohara
Copy link

scottohara commented Jul 21, 2022

Is there any likelihood of this PR getting merged, or is karma-mocha essentially an abandoned/unmaintained project at this point?

(Please accept that this is a genuine question, I'm not trying to be rude.)

It's been a while since I've done anything with karma, but recently I had cause to revisit an old project to upgrade the version of sinon.js it used, and in the process I discovered that as of SinonJS v11, potential memory leaks are reported and the recommendation is to call sinon.restore() in an afterEach hook of every test suite.

This would seem to be a perfect use case for Mocha v8.0.0+ root hooks, hence what has led me to this PR.

I also note that in #209 it was mentioned that

#218 should allow release to be driven by successful post-commit tests.

...but it is unclear what in practice that means for this project as there has only been 1 release since that comment, despite the backlog of PRs such as this one that appear to have passed all checks?

If the answer is that yes, there are no maintainers and/or volunteers are wanted (which is perfectly understandable), perhaps a note could be added to the README?

@romanc romanc mentioned this pull request Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants