Skip to content

Commit 2e33858

Browse files
author
DavertMik
committed
added debug for container, fixed check command
1 parent 4fa6023 commit 2e33858

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

lib/command/check.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ module.exports = async function (test, options) {
5353

5454
printCheck('container', checks['container'])
5555

56-
if (codecept && options.bootstrap) {
56+
if (codecept) {
5757
try {
58-
await codecept.bootstrap()
58+
if (options.bootstrap) await codecept.bootstrap()
5959
checks.bootstrap = true
6060
} catch (err) {
6161
checks.bootstrap = err
6262
}
63-
printCheck('bootstrap', checks['bootstrap'])
63+
printCheck('bootstrap', checks['bootstrap'], options.bootstrap ? 'Bootstrap was executed' : 'No bootstrap command')
6464
}
6565

6666
let numTests = 0
@@ -121,20 +121,20 @@ module.exports = async function (test, options) {
121121
const test = createTest('test', () => {})
122122
try {
123123
for (const helper of Object.values(helpers)) {
124-
await helper._beforeSuite(suite)
125-
await helper._before(test)
126-
await helper._passed(test)
127-
await helper._after(test)
128-
await helper._finishTest(suite)
129-
await helper._afterSuite(suite)
124+
if (helper._beforeSuite) await helper._beforeSuite(suite)
125+
if (helper._before) await helper._before(test)
126+
if (helper._passed) await helper._passed(test)
127+
if (helper._after) await helper._after(test)
128+
if (helper._finishTest) await helper._finishTest(suite)
129+
if (helper._afterSuite) await helper._afterSuite(suite)
130130
}
131131
checks.setup = true
132132
} catch (err) {
133133
checks.setup = err
134134
}
135135
}
136136

137-
printCheck('Helpers Hooks', checks['setup'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Initializing and closing browser' : '')
137+
printCheck('Helpers Before/After', checks['setup'], standardActingHelpers.some(h => Object.keys(helpers).includes(h)) ? 'Initializing and closing browser' : '')
138138

139139
try {
140140
definitions(configFile, { dryRun: true })

lib/container.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const glob = require('glob')
22
const path = require('path')
3+
const debug = require('debug')('codeceptjs:container')
34
const { MetaStep } = require('./step')
45
const { methodsOfObject, fileExists, isFunction, isAsyncFunction, installedLocally } = require('./utils')
56
const Translation = require('./translation')
@@ -38,6 +39,7 @@ class Container {
3839
* @param {*} opts
3940
*/
4041
static create(config, opts) {
42+
debug('creating container')
4143
asyncHelperPromise = Promise.resolve()
4244

4345
// dynamically create mocha instance
@@ -134,6 +136,7 @@ class Container {
134136
static append(newContainer) {
135137
const deepMerge = require('./utils').deepMerge
136138
container = deepMerge(container, newContainer)
139+
debug('appended', JSON.stringify(newContainer).slice(0, 300))
137140
}
138141

139142
/**
@@ -150,6 +153,7 @@ class Container {
150153
container.plugins = newPlugins || {}
151154
asyncHelperPromise = Promise.resolve()
152155
store.actor = null
156+
debug('container cleared')
153157
}
154158

155159
/**
@@ -216,6 +220,8 @@ function createHelpers(config) {
216220
throw new Error(`Helper class from module '${helperName}' is not a class. Use CJS async module syntax.`)
217221
}
218222

223+
debug(`helper ${helperName} async initialized`)
224+
219225
helpers[helperName] = new ResolvedHelperClass(config[helperName])
220226
})
221227

@@ -225,6 +231,7 @@ function createHelpers(config) {
225231
checkHelperRequirements(HelperClass)
226232

227233
helpers[helperName] = new HelperClass(config[helperName])
234+
debug(`helper ${helperName} initialized`)
228235
} catch (err) {
229236
throw new Error(`Could not load helper ${helperName} (${err.message})`)
230237
}
@@ -322,6 +329,7 @@ function createSupportObjects(config) {
322329
if (container.support[name]._init) {
323330
container.support[name]._init()
324331
}
332+
debug(`support object ${name} initialized`)
325333
} catch (err) {
326334
throw new Error(`Initialization failed for ${name}: ${container.support[name]}\n${err.message}\n${err.stack}`)
327335
}
@@ -334,6 +342,7 @@ function createSupportObjects(config) {
334342
const ms = new MetaStep(name, prop)
335343
ms.setContext(currentObject)
336344
if (isAsyncFunction(currentValue)) currentValue = asyncWrapper(currentValue)
345+
debug(`metastep is created for ${name}.${prop.toString()}()`)
337346
return ms.run.bind(ms, currentValue)
338347
}
339348

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"fn-args": "4.0.0",
9494
"fs-extra": "11.2.0",
9595
"glob": "^11.0.0",
96+
"fuse.js": "^7.0.0",
9697
"html-minifier-terser": "7.2.0",
9798
"inquirer": "6.5.2",
9899
"invisi-data": "^1.0.0",

0 commit comments

Comments
 (0)