tapjs icon indicating copy to clipboard operation
tapjs copied to clipboard

[BUG] mocha-globals before/after hook functions no longer support a done function?

Open Qard opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Have you read the CONTRIBUTING guide on posting bugs, and CODE_OF_CONDUCT?

  • [X] yes I read the things

This issue exists in the latest tap version

  • [X] I am using the latest tap

Description

Prior to 18.x before/after functions accepted hook functions which took a callback to execute later. This functionality seems to have disappeared without any mention in the upgrade guide. Was this an intentional change?

Reproduction

before((done) => {
  setImmediate(done)
})

Environment

./node_modules/.bin/tap
[email protected] /Users/stephen.belanger/Code/dd-trace-js
└── [email protected]

tap: 18.7.0
"@tapjs/config": 2.4.15
"@tapjs/core": 1.5.0
"@tapjs/run": 1.5.0
"@tapjs/stack": 1.2.7
"@tapjs/test": 1.4.0
tap-parser: 15.3.1
tap-yaml: 2.2.1
tcompare: 6.4.5
plugins:
  "@tapjs/after": 1.1.18
  "@tapjs/after-each": 1.1.18
  "@tapjs/asserts": 1.1.18
  "@tapjs/before": 1.1.18
  "@tapjs/before-each": 1.1.18
  "@tapjs/filter": 1.2.18
  "@tapjs/fixture": 1.2.18
  "@tapjs/intercept": 1.2.18
  "@tapjs/mocha-globals": 1.1.18
  "@tapjs/mock": 1.3.0
  "@tapjs/node-serialize": 1.3.0
  "@tapjs/snapshot": 1.2.18
  "@tapjs/spawn": 1.1.18
  "@tapjs/stdin": 1.1.18
  "@tapjs/typescript": 1.4.0
  "@tapjs/worker": 1.1.18
# vim: set filetype=yaml :

# from .taprc
allow-incomplete-coverage: true
color: true
disable-coverage: true
node-arg:
  - --expose-gc
plugin:
  - "@tapjs/mocha-globals"

# env, cli, and defaults
coverage-report:
  - text
exclude:
  - "**/@(fixture*(s)|dist)/**"
include:
  - "**/@(test?(s)|__test?(s)__)/**/*.@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/*.@(test?(s)|spec).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
  - "**/test?(s).@(js|cjs|mjs|tap|cts|jsx|mts|ts|tsx)"
jobs: 8
mocha-globals: true
reporter: base
snapshot-clean-cwd: true
timeout: 30
@tapjs/after
@tapjs/after-each
@tapjs/asserts
@tapjs/before
@tapjs/before-each
@tapjs/filter
@tapjs/fixture
@tapjs/intercept
@tapjs/mock
@tapjs/node-serialize
@tapjs/snapshot
@tapjs/spawn
@tapjs/stdin
@tapjs/typescript
@tapjs/worker
@tapjs/mocha-globals
Darwin COMP-JX471G9FQQ 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64 arm Darwin

Qard avatar Mar 07 '24 01:03 Qard

Correct, this is a corollary of the fact that lifecycle methods don't get callbacks, they're just promise-returning.

Doc patch welcome, or I guess I'd be open to bringing that back, but tbh, it was always a bit flaky having it do both. Now it's closer to modern Mocha's type, where HookBlock is just () => void | any | Promise<void | any>

isaacs avatar Mar 08 '24 00:03 isaacs