codeceptjs 4.0.8 → 4.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,25 @@ Make sure `Playwright` helper is enabled in `codecept.conf.js` config:
63
63
  > Turn off the `show` option if you want to run test in headless mode.
64
64
  > If you don't specify the browser here, `chromium` will be used. Possible browsers are: `chromium`, `firefox` and `webkit`
65
65
 
66
+ To point `firefox` at a custom build instead of the bundled one, pass `executablePath` under the
67
+ `firefox` key:
68
+
69
+ ```js
70
+ helpers: {
71
+ Playwright: {
72
+ url: "http://localhost",
73
+ browser: 'firefox',
74
+ firefox: {
75
+ executablePath: '/path/to/firefox'
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ Useful with a build like [invisible_playwright](https://github.com/feder-cr/invisible_playwright),
82
+ patched at the source level for a realistic fingerprint, for sites that detect the default Chromium
83
+ path.
84
+
66
85
  Playwright uses different strategies to detect if a page is loaded. In configuration use `waitForNavigation` option for that:
67
86
 
68
87
  When to consider navigation succeeded, defaults to `load`. Given an array of event strings, navigation is considered to be successful after all events have been fired. Events can be either:
@@ -82,8 +82,13 @@ function isTableDataRow(row) {
82
82
  return has.call(row, 'data') && has.call(row, 'skip')
83
83
  }
84
84
 
85
+ function isDataTable(dataTable) {
86
+ if (dataTable instanceof DataTable) return true
87
+ return Boolean(dataTable) && Array.isArray(dataTable.array) && Array.isArray(dataTable.rows) && typeof dataTable.add === 'function'
88
+ }
89
+
85
90
  function detectDataType(dataTable) {
86
- if (dataTable instanceof DataTable) {
91
+ if (isDataTable(dataTable)) {
87
92
  return dataTable.rows
88
93
  }
89
94
 
package/lib/globals.js CHANGED
@@ -30,10 +30,8 @@ export async function initCodeceptGlobals(dir, config, container) {
30
30
  // pause/inject/share stay global even under noGlobals — they're the everyday
31
31
  // debugging/wiring entry points and have no useful import alternative for
32
32
  // page-object code that runs before the container is available.
33
- global.pause = async (...args) => {
34
- const pauseModule = await import('./pause.js')
35
- return (pauseModule.default || pauseModule)(...args)
36
- }
33
+ const pauseModule = await import('./pause.js')
34
+ global.pause = pauseModule.default || pauseModule
37
35
  global.inject = () => container.support()
38
36
  global.share = container.share
39
37
 
@@ -53,14 +53,6 @@ class GraphQL extends Helper {
53
53
  this.axios.defaults.headers = this.options.defaultHeaders
54
54
  }
55
55
 
56
- static _checkRequirements() {
57
- try {
58
- require('axios')
59
- } catch (e) {
60
- return ['axios']
61
- }
62
- }
63
-
64
56
  static _config() {
65
57
  return [
66
58
  {
@@ -174,15 +174,6 @@ class GraphQLDataFactory extends Helper {
174
174
  Object.keys(this.factories).forEach(f => (this.created[f] = []))
175
175
  }
176
176
 
177
- static _checkRequirements() {
178
- try {
179
- require('axios')
180
- require('rosie')
181
- } catch (e) {
182
- return ['axios', 'rosie']
183
- }
184
- }
185
-
186
177
  _after() {
187
178
  if (!this.config.cleanup) {
188
179
  return Promise.resolve()
@@ -66,6 +66,26 @@ export default function (config = {}) {
66
66
  config = Object.assign({}, defaultConfig, config)
67
67
 
68
68
  let written = false
69
+ const hookFailures = []
70
+
71
+ event.dispatcher.on(event.hook.failed, hook => {
72
+ if (!hook || !['BeforeSuite', 'AfterSuite'].includes(hook.hookName)) return
73
+ const err = hook.err || hook.error
74
+ if (!err) return
75
+ const runnable = hook.ctx && hook.ctx.test
76
+ const suite = runnable && runnable.parent
77
+ hookFailures.push({
78
+ title: hook.title || `${hook.hookName} hook failed`,
79
+ state: 'failed',
80
+ err,
81
+ parent: suite,
82
+ file: (runnable && runnable.file) || (suite && suite.file),
83
+ tags: (suite && suite.tags) || [],
84
+ meta: {},
85
+ steps: [],
86
+ duration: (runnable && runnable.duration) || 0,
87
+ })
88
+ })
69
89
 
70
90
  const writeReport = result => {
71
91
  if (written) return
@@ -76,7 +96,7 @@ export default function (config = {}) {
76
96
  mkdirp.sync(dir)
77
97
  const file = path.join(dir, config.outputName)
78
98
 
79
- fs.writeFileSync(file, buildXml(result, config))
99
+ fs.writeFileSync(file, buildXml(result, config, hookFailures))
80
100
  output.plugin('junitReporter', `JUnit report saved to ${file}`)
81
101
  }
82
102
 
@@ -84,17 +104,18 @@ export default function (config = {}) {
84
104
  event.dispatcher.on(event.workers.result, writeReport)
85
105
  }
86
106
 
87
- function buildXml(result, config) {
107
+ function buildXml(result, config, hookFailures = []) {
88
108
  const doc = new DOMImplementation().createDocument(null, null, null)
89
- const suites = groupBySuite(result.tests)
109
+ const allTests = result.tests.concat(hookFailures)
110
+ const suites = groupBySuite(allTests)
90
111
 
91
112
  const root = doc.createElement('testsuites')
92
113
  setAttr(root, 'name', config.testGroupName)
93
- setAttr(root, 'tests', result.tests.length)
94
- setAttr(root, 'failures', countState(result.tests, 'failed'))
95
- setAttr(root, 'skipped', countSkipped(result.tests))
114
+ setAttr(root, 'tests', allTests.length)
115
+ setAttr(root, 'failures', countState(allTests, 'failed'))
116
+ setAttr(root, 'skipped', countSkipped(allTests))
96
117
  setAttr(root, 'errors', 0)
97
- setAttr(root, 'time', toSeconds(sumDuration(result.tests)))
118
+ setAttr(root, 'time', toSeconds(sumDuration(allTests)))
98
119
  setAttr(root, 'timestamp', toIso(result.stats && result.stats.start))
99
120
  doc.appendChild(root)
100
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "type": "module",
5
5
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
6
6
  "keywords": [