Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mocha/asyncWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function setup(suite) {
recorder.startUnlessRunning()
import('./test.js').then(testModule => {
const { enhanceMochaTest } = testModule.default || testModule
event.emit(event.test.before, enhanceMochaTest(suite?.ctx?.currentTest))
event.emit(event.test.before, enhanceMochaTest(suite?.currentTest ?? suite?.ctx?.currentTest))
recorder.add(() => doneFn())
})
}
Expand All @@ -211,7 +211,7 @@ export function teardown(suite) {
recorder.startUnlessRunning()
import('./test.js').then(testModule => {
const { enhanceMochaTest } = testModule.default || testModule
event.emit(event.test.after, enhanceMochaTest(suite?.ctx?.currentTest))
event.emit(event.test.after, enhanceMochaTest(suite?.currentTest ?? suite?.ctx?.currentTest))
recorder.add(() => doneFn())
})
}
Expand Down
11 changes: 5 additions & 6 deletions lib/mocha/gherkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ const gherkinParser = (text, file) => {
suite.file = file
suite.timeout(0)

suite.beforeEach('codeceptjs.before', function () {
// In Mocha, 'this' refers to the current test in beforeEach/afterEach hooks
setup(this)(() => {})
suite.beforeEach('codeceptjs.before', function (done) {
// In Mocha, 'this' is the hook Context; currentTest is the running scenario
setup(this)(done)
})
suite.afterEach('codeceptjs.after', function () {
// In Mocha, 'this' refers to the current test in beforeEach/afterEach hooks
teardown(this)(() => {})
suite.afterEach('codeceptjs.after', function (done) {
teardown(this)(done)
})
suite.beforeAll('codeceptjs.beforeSuite', suiteSetup(suite))
suite.afterAll('codeceptjs.afterSuite', suiteTeardown(suite))
Expand Down