Skip to content

Commit a40026d

Browse files
author
DavertMik
committed
check improvements
1 parent 518d5fc commit a40026d

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

lib/command/check.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = async function (options) {
2525
ai: true, // we don't need to check AI
2626
helpers: false,
2727
setup: false,
28+
teardown: false,
2829
tests: false,
2930
def: false,
3031
}
@@ -131,22 +132,36 @@ module.exports = async function (options) {
131132
if (Object.keys(helpers).length) {
132133
const suite = container.mocha().suite
133134
const test = createTest('test', () => {})
134-
try {
135-
for (const helper of Object.values(helpers)) {
135+
checks.setup = true
136+
for (const helper of Object.values(helpers)) {
137+
try {
136138
if (helper._beforeSuite) await helper._beforeSuite(suite)
137139
if (helper._before) await helper._before(test)
140+
} catch (err) {
141+
err.message = `${helper.constructor.name} helper: ${err.message}`
142+
if (checks.setup instanceof Error) err.message = `${err.message}\n\n${checks.setup?.message || ''}`.trim()
143+
checks.setup = err
144+
}
145+
}
146+
147+
printCheck('Helpers Before', checks['setup'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Initializing browser' : '')
148+
149+
checks.teardown = true
150+
for (const helper of Object.values(helpers).reverse()) {
151+
try {
138152
if (helper._passed) await helper._passed(test)
139153
if (helper._after) await helper._after(test)
140154
if (helper._finishTest) await helper._finishTest(suite)
141155
if (helper._afterSuite) await helper._afterSuite(suite)
156+
} catch (err) {
157+
err.message = `${helper.constructor.name} helper: ${err.message}`
158+
if (checks.teardown instanceof Error) err.message = `${err.message}\n\n${checks.teardown?.message || ''}`.trim()
159+
checks.teardown = err
142160
}
143-
checks.setup = true
144-
} catch (err) {
145-
checks.setup = err
146161
}
147-
}
148162

149-
printCheck('Helpers Before/After', checks['setup'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Initializing and closing browser' : '')
163+
printCheck('Helpers After', checks['teardown'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Closing browser' : '')
164+
}
150165

151166
try {
152167
definitions(configFile, { dryRun: true })

lib/plugin/retryTo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const defaultConfig = {
66

77
module.exports = function (config) {
88
config = Object.assign(defaultConfig, config)
9-
console.log(`Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module`)
9+
console.log(`Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.`)
1010

1111
if (config.registerGlobal) {
1212
global.retryTo = retryTo

lib/plugin/tryTo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const defaultConfig = {
66

77
module.exports = function (config) {
88
config = Object.assign(defaultConfig, config)
9-
console.log(`Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module`)
9+
console.log(`Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.`)
1010

1111
if (config.registerGlobal) {
1212
global.tryTo = tryTo

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeceptjs",
3-
"version": "3.7.0-beta.16",
3+
"version": "3.7.0-beta.19",
44
"description": "Supercharged End 2 End Testing Framework for NodeJS",
55
"keywords": [
66
"acceptance",

0 commit comments

Comments
 (0)