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

Await all script type="module" before mocha.run #244

Closed
wants to merge 1 commit into from

Conversation

loynoir
Copy link

@loynoir loynoir commented Oct 24, 2021

Tested solved #243

@loynoir
Copy link
Author

loynoir commented Oct 25, 2021

$ git clone https://github.com/loynoir/reproduce-karmaMocha-237.mjs .
$ pnpm install
$ pnpm test
  CJS
    ✔ bar
  fastESM
    ✔ bar

SUMMARY:
✔ 2 tests completed
$ pnpm remove karma-mocha && pnpm install https://github.com/loynoir/karma-mocha && pnpm test
  CJS
    ✔ bar
  fastESM
    ✔ bar
  slowESM
    ✔ bar

SUMMARY:
✔ 3 tests completed

@google-cla
Copy link

google-cla bot commented Oct 28, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@loynoir loynoir reopened this Oct 28, 2021
@loynoir
Copy link
Author

loynoir commented Oct 28, 2021

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

Fixme/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.

@loynoir loynoir closed this Oct 28, 2021
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.

None yet

1 participant