codeceptjs 3.7.6-beta.4 → 4.0.0-beta.10.esm-aria
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.
- package/README.md +1 -3
- package/bin/codecept.js +51 -53
- package/bin/test-server.js +14 -3
- package/docs/webapi/click.mustache +5 -1
- package/lib/actor.js +15 -11
- package/lib/ai.js +72 -107
- package/lib/assert/empty.js +9 -8
- package/lib/assert/equal.js +15 -17
- package/lib/assert/error.js +2 -2
- package/lib/assert/include.js +9 -11
- package/lib/assert/throws.js +1 -1
- package/lib/assert/truth.js +8 -5
- package/lib/assert.js +18 -18
- package/lib/codecept.js +102 -75
- package/lib/colorUtils.js +48 -50
- package/lib/command/check.js +32 -27
- package/lib/command/configMigrate.js +11 -10
- package/lib/command/definitions.js +16 -10
- package/lib/command/dryRun.js +16 -16
- package/lib/command/generate.js +62 -27
- package/lib/command/gherkin/init.js +36 -38
- package/lib/command/gherkin/snippets.js +14 -14
- package/lib/command/gherkin/steps.js +21 -18
- package/lib/command/info.js +8 -8
- package/lib/command/init.js +36 -29
- package/lib/command/interactive.js +11 -10
- package/lib/command/list.js +10 -9
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +3 -3
- package/lib/command/run-multiple.js +16 -13
- package/lib/command/run-rerun.js +6 -7
- package/lib/command/run-workers.js +24 -9
- package/lib/command/run.js +23 -8
- package/lib/command/utils.js +20 -18
- package/lib/command/workers/runTests.js +197 -114
- package/lib/config.js +124 -51
- package/lib/container.js +438 -87
- package/lib/data/context.js +6 -5
- package/lib/data/dataScenarioConfig.js +1 -1
- package/lib/data/dataTableArgument.js +1 -1
- package/lib/data/table.js +1 -1
- package/lib/effects.js +94 -10
- package/lib/element/WebElement.js +2 -2
- package/lib/els.js +11 -9
- package/lib/event.js +11 -10
- package/lib/globals.js +141 -0
- package/lib/heal.js +12 -12
- package/lib/helper/AI.js +11 -11
- package/lib/helper/ApiDataFactory.js +50 -19
- package/lib/helper/Appium.js +19 -27
- package/lib/helper/FileSystem.js +32 -12
- package/lib/helper/GraphQL.js +3 -3
- package/lib/helper/GraphQLDataFactory.js +4 -4
- package/lib/helper/JSONResponse.js +25 -29
- package/lib/helper/Mochawesome.js +7 -4
- package/lib/helper/Playwright.js +902 -164
- package/lib/helper/Puppeteer.js +383 -76
- package/lib/helper/REST.js +29 -12
- package/lib/helper/WebDriver.js +268 -61
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- package/lib/helper/errors/ConnectionRefused.js +6 -6
- package/lib/helper/errors/ElementAssertion.js +11 -16
- package/lib/helper/errors/ElementNotFound.js +5 -9
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
- package/lib/helper/extras/Console.js +11 -11
- package/lib/helper/extras/PlaywrightLocator.js +110 -0
- package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
- package/lib/helper/extras/PlaywrightReactVueLocator.js +18 -9
- package/lib/helper/extras/PlaywrightRestartOpts.js +34 -23
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +29 -30
- package/lib/helper/network/actions.js +29 -44
- package/lib/helper/network/utils.js +76 -83
- package/lib/helper/scripts/blurElement.js +6 -6
- package/lib/helper/scripts/focusElement.js +6 -6
- package/lib/helper/scripts/highlightElement.js +9 -9
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -1
- package/lib/history.js +23 -20
- package/lib/hooks.js +10 -10
- package/lib/html.js +90 -100
- package/lib/index.js +48 -21
- package/lib/listener/config.js +19 -12
- package/lib/listener/emptyRun.js +6 -7
- package/lib/listener/enhancedGlobalRetry.js +6 -6
- package/lib/listener/exit.js +4 -3
- package/lib/listener/globalRetry.js +5 -5
- package/lib/listener/globalTimeout.js +30 -14
- package/lib/listener/helpers.js +39 -14
- package/lib/listener/mocha.js +3 -4
- package/lib/listener/result.js +4 -5
- package/lib/listener/retryEnhancer.js +3 -3
- package/lib/listener/steps.js +8 -7
- package/lib/listener/store.js +3 -3
- package/lib/locator.js +213 -192
- package/lib/mocha/asyncWrapper.js +105 -62
- package/lib/mocha/bdd.js +99 -13
- package/lib/mocha/cli.js +59 -26
- package/lib/mocha/factory.js +78 -19
- package/lib/mocha/featureConfig.js +1 -1
- package/lib/mocha/gherkin.js +56 -24
- package/lib/mocha/hooks.js +12 -3
- package/lib/mocha/index.js +13 -4
- package/lib/mocha/inject.js +22 -5
- package/lib/mocha/scenarioConfig.js +2 -2
- package/lib/mocha/suite.js +9 -2
- package/lib/mocha/test.js +10 -7
- package/lib/mocha/ui.js +28 -18
- package/lib/output.js +10 -8
- package/lib/parser.js +44 -44
- package/lib/pause.js +15 -16
- package/lib/plugin/analyze.js +19 -12
- package/lib/plugin/auth.js +20 -21
- package/lib/plugin/autoDelay.js +12 -8
- package/lib/plugin/coverage.js +28 -11
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/customReporter.js +3 -2
- package/lib/plugin/enhancedRetryFailedStep.js +6 -6
- package/lib/plugin/heal.js +14 -9
- package/lib/plugin/htmlReporter.js +724 -99
- package/lib/plugin/pageInfo.js +10 -10
- package/lib/plugin/pauseOnFail.js +4 -3
- package/lib/plugin/retryFailedStep.js +48 -5
- package/lib/plugin/screenshotOnFail.js +75 -37
- package/lib/plugin/stepByStepReport.js +14 -14
- package/lib/plugin/stepTimeout.js +4 -3
- package/lib/plugin/subtitles.js +6 -5
- package/lib/recorder.js +33 -14
- package/lib/rerun.js +69 -26
- package/lib/result.js +4 -4
- package/lib/retryCoordinator.js +2 -2
- package/lib/secret.js +18 -17
- package/lib/session.js +95 -89
- package/lib/step/base.js +7 -7
- package/lib/step/comment.js +2 -2
- package/lib/step/config.js +1 -1
- package/lib/step/func.js +3 -3
- package/lib/step/helper.js +3 -3
- package/lib/step/meta.js +5 -5
- package/lib/step/record.js +11 -11
- package/lib/step/retry.js +3 -3
- package/lib/step/section.js +3 -3
- package/lib/step.js +7 -10
- package/lib/steps.js +9 -5
- package/lib/store.js +1 -1
- package/lib/template/heal.js +1 -1
- package/lib/template/prompts/generatePageObject.js +31 -0
- package/lib/template/prompts/healStep.js +13 -0
- package/lib/template/prompts/writeStep.js +9 -0
- package/lib/test-server.js +17 -6
- package/lib/timeout.js +1 -7
- package/lib/transform.js +8 -8
- package/lib/translation.js +32 -18
- package/lib/utils/mask_data.js +4 -10
- package/lib/utils.js +66 -64
- package/lib/workerStorage.js +17 -17
- package/lib/workers.js +214 -84
- package/package.json +41 -37
- package/translations/de-DE.js +2 -2
- package/translations/fr-FR.js +2 -2
- package/translations/index.js +23 -10
- package/translations/it-IT.js +2 -2
- package/translations/ja-JP.js +2 -2
- package/translations/nl-NL.js +2 -2
- package/translations/pl-PL.js +2 -2
- package/translations/pt-BR.js +2 -2
- package/translations/ru-RU.js +2 -2
- package/translations/utils.js +4 -3
- package/translations/zh-CN.js +2 -2
- package/translations/zh-TW.js +2 -2
- package/typings/index.d.ts +5 -3
- package/typings/promiseBasedTypes.d.ts +4 -0
- package/typings/types.d.ts +4 -0
- package/lib/helper/Nightmare.js +0 -1486
- package/lib/helper/Protractor.js +0 -1840
- package/lib/helper/TestCafe.js +0 -1391
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -61
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/autoLogin.js +0 -5
- package/lib/plugin/commentStep.js +0 -141
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/retryTo.js +0 -16
- package/lib/plugin/selenoid.js +0 -364
- package/lib/plugin/standardActingHelpers.js +0 -6
- package/lib/plugin/tryTo.js +0 -16
- package/lib/plugin/wdio.js +0 -247
- package/lib/within.js +0 -90
package/lib/helper/Appium.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import * as webdriverio from 'webdriverio'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
5
|
+
|
|
6
|
+
import Webdriver from './WebDriver.js'
|
|
7
|
+
import AssertionFailedError from '../assert/error.js'
|
|
8
|
+
import { truth } from '../assert/truth.js'
|
|
9
|
+
import recorder from '../recorder.js'
|
|
10
|
+
import Locator from '../locator.js'
|
|
11
|
+
import ConnectionRefused from './errors/ConnectionRefused.js'
|
|
12
|
+
import ElementNotFound from './errors/ElementNotFound.js'
|
|
13
|
+
import { dontSeeElementError } from './errors/ElementAssertion.js'
|
|
13
14
|
|
|
14
15
|
const mobileRoot = '//*'
|
|
15
16
|
const webRoot = 'body'
|
|
@@ -181,7 +182,6 @@ class Appium extends Webdriver {
|
|
|
181
182
|
this.appiumV2 = config.appiumV2 || true
|
|
182
183
|
this.axios = axios.create()
|
|
183
184
|
|
|
184
|
-
webdriverio = require('webdriverio')
|
|
185
185
|
if (!config.appiumV2) {
|
|
186
186
|
console.log('The Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022. Appium 2.x is used by default.')
|
|
187
187
|
console.log('More info: https://bit.ly/appium-v2-migration')
|
|
@@ -1549,11 +1549,9 @@ class Appium extends Webdriver {
|
|
|
1549
1549
|
// For mobile native apps, use safe isDisplayed wrapper
|
|
1550
1550
|
const parsedLocator = parseLocator.call(this, locator)
|
|
1551
1551
|
const res = await this._locate(parsedLocator, false)
|
|
1552
|
-
const { truth } = require('../assert/truth')
|
|
1553
|
-
const Locator = require('../locator')
|
|
1554
1552
|
|
|
1555
1553
|
if (!res || res.length === 0) {
|
|
1556
|
-
return truth(`elements of ${
|
|
1554
|
+
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').negate(false)
|
|
1557
1555
|
}
|
|
1558
1556
|
|
|
1559
1557
|
const selected = []
|
|
@@ -1563,7 +1561,7 @@ class Appium extends Webdriver {
|
|
|
1563
1561
|
}
|
|
1564
1562
|
|
|
1565
1563
|
try {
|
|
1566
|
-
return truth(`elements of ${
|
|
1564
|
+
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').negate(selected)
|
|
1567
1565
|
} catch (err) {
|
|
1568
1566
|
throw err
|
|
1569
1567
|
}
|
|
@@ -1714,10 +1712,6 @@ class Appium extends Webdriver {
|
|
|
1714
1712
|
// For mobile native apps, use safe isDisplayed wrapper
|
|
1715
1713
|
const parsedLocator = parseLocator.call(this, locator)
|
|
1716
1714
|
const res = await this._locate(parsedLocator, true)
|
|
1717
|
-
const ElementNotFound = require('./errors/ElementNotFound')
|
|
1718
|
-
const { truth } = require('../assert/truth')
|
|
1719
|
-
const { dontSeeElementError } = require('./errors/ElementAssertion')
|
|
1720
|
-
const Locator = require('../locator')
|
|
1721
1715
|
|
|
1722
1716
|
if (!res || res.length === 0) {
|
|
1723
1717
|
throw new ElementNotFound(parsedLocator)
|
|
@@ -1730,7 +1724,7 @@ class Appium extends Webdriver {
|
|
|
1730
1724
|
}
|
|
1731
1725
|
|
|
1732
1726
|
try {
|
|
1733
|
-
return truth(`elements of ${
|
|
1727
|
+
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').assert(selected)
|
|
1734
1728
|
} catch (e) {
|
|
1735
1729
|
dontSeeElementError(parsedLocator)
|
|
1736
1730
|
}
|
|
@@ -1784,7 +1778,6 @@ class Appium extends Webdriver {
|
|
|
1784
1778
|
// For mobile native apps, use safe isDisplayed wrapper
|
|
1785
1779
|
const parsedLocator = parseLocator.call(this, locator)
|
|
1786
1780
|
const aSec = sec || this.options.waitForTimeoutInSeconds
|
|
1787
|
-
const Locator = require('../locator')
|
|
1788
1781
|
|
|
1789
1782
|
return this.browser.waitUntil(
|
|
1790
1783
|
async () => {
|
|
@@ -1801,7 +1794,7 @@ class Appium extends Webdriver {
|
|
|
1801
1794
|
},
|
|
1802
1795
|
{
|
|
1803
1796
|
timeout: aSec * 1000,
|
|
1804
|
-
timeoutMsg: `element (${
|
|
1797
|
+
timeoutMsg: `element (${Locator.build(parsedLocator)}) still not visible after ${aSec} sec`,
|
|
1805
1798
|
},
|
|
1806
1799
|
)
|
|
1807
1800
|
}
|
|
@@ -1816,7 +1809,6 @@ class Appium extends Webdriver {
|
|
|
1816
1809
|
// For mobile native apps, use safe isDisplayed wrapper
|
|
1817
1810
|
const parsedLocator = parseLocator.call(this, locator)
|
|
1818
1811
|
const aSec = sec || this.options.waitForTimeoutInSeconds
|
|
1819
|
-
const Locator = require('../locator')
|
|
1820
1812
|
|
|
1821
1813
|
return this.browser.waitUntil(
|
|
1822
1814
|
async () => {
|
|
@@ -1831,7 +1823,7 @@ class Appium extends Webdriver {
|
|
|
1831
1823
|
|
|
1832
1824
|
return selected.length === 0
|
|
1833
1825
|
},
|
|
1834
|
-
{ timeout: aSec * 1000, timeoutMsg: `element (${
|
|
1826
|
+
{ timeout: aSec * 1000, timeoutMsg: `element (${Locator.build(parsedLocator)}) still visible after ${aSec} sec` },
|
|
1835
1827
|
)
|
|
1836
1828
|
}
|
|
1837
1829
|
|
|
@@ -1908,4 +1900,4 @@ function onlyForApps(expectedPlatform) {
|
|
|
1908
1900
|
}
|
|
1909
1901
|
}
|
|
1910
1902
|
|
|
1911
|
-
|
|
1903
|
+
export default Appium
|
package/lib/helper/FileSystem.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs from 'fs'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import Helper from '@codeceptjs/helper'
|
|
6
|
+
import { fileExists } from '../utils.js'
|
|
7
|
+
import { fileIncludes } from '../assert/include.js'
|
|
8
|
+
import { fileEquals } from '../assert/equal.js'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Helper for testing filesystem.
|
|
@@ -38,7 +38,12 @@ class FileSystem extends Helper {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
_before() {
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
this.debugSection('Dir', this.dir)
|
|
43
|
+
} catch (e) {
|
|
44
|
+
// Fallback debug for ESM transition
|
|
45
|
+
console.log(`[Dir] ${this.dir}`)
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
/**
|
|
@@ -48,7 +53,12 @@ class FileSystem extends Helper {
|
|
|
48
53
|
*/
|
|
49
54
|
amInPath(openPath) {
|
|
50
55
|
this.dir = path.join(global.codecept_dir, openPath)
|
|
51
|
-
|
|
56
|
+
try {
|
|
57
|
+
this.debugSection('Dir', this.dir)
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// Fallback debug for ESM transition
|
|
60
|
+
console.log(`[Dir] ${this.dir}`)
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
/**
|
|
@@ -66,7 +76,12 @@ class FileSystem extends Helper {
|
|
|
66
76
|
*/
|
|
67
77
|
seeFile(name) {
|
|
68
78
|
this.file = path.join(this.dir, name)
|
|
69
|
-
|
|
79
|
+
try {
|
|
80
|
+
this.debugSection('File', this.file)
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// Fallback debug for ESM transition
|
|
83
|
+
console.log(`[File] ${this.file}`)
|
|
84
|
+
}
|
|
70
85
|
assert.ok(fileExists(this.file), `File ${name} not found in ${this.dir}`)
|
|
71
86
|
}
|
|
72
87
|
|
|
@@ -86,7 +101,12 @@ class FileSystem extends Helper {
|
|
|
86
101
|
if (sec === 0) assert.fail('Use `seeFile` instead of waiting 0 seconds!')
|
|
87
102
|
const waitTimeout = sec * 1000
|
|
88
103
|
this.file = path.join(this.dir, name)
|
|
89
|
-
|
|
104
|
+
try {
|
|
105
|
+
this.debugSection('File', this.file)
|
|
106
|
+
} catch (e) {
|
|
107
|
+
// Fallback debug for ESM transition
|
|
108
|
+
console.log(`[File] ${this.file}`)
|
|
109
|
+
}
|
|
90
110
|
return isFileExists(this.file, waitTimeout).catch(() => {
|
|
91
111
|
throw new Error(`file (${name}) still not present in directory ${this.dir} after ${waitTimeout / 1000} sec`)
|
|
92
112
|
})
|
|
@@ -179,7 +199,7 @@ class FileSystem extends Helper {
|
|
|
179
199
|
}
|
|
180
200
|
}
|
|
181
201
|
|
|
182
|
-
|
|
202
|
+
export { FileSystem as default }
|
|
183
203
|
|
|
184
204
|
/**
|
|
185
205
|
* @param {string} file
|
package/lib/helper/GraphQL.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import HelperModule from '@codeceptjs/helper'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* GraphQL helper allows to send additional requests to a GraphQl endpoint during acceptance tests.
|
|
@@ -227,4 +227,4 @@ class GraphQL extends Helper {
|
|
|
227
227
|
this.haveRequestHeaders({ Authorization: `Bearer ${accessToken}` })
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
export default GraphQL
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import HelperModule from '@codeceptjs/helper'
|
|
4
|
+
import GraphQL from './GraphQL.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Helper for managing remote data using GraphQL queries.
|
|
@@ -305,4 +305,4 @@ class GraphQLDataFactory extends Helper {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
export default GraphQLDataFactory
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import Helper from '@codeceptjs/helper'
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import { z } from 'zod'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This helper allows performing assertions on JSON responses paired with following helpers:
|
|
@@ -83,14 +83,7 @@ class JSONResponse extends Helper {
|
|
|
83
83
|
this.response = null
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
require('joi')
|
|
89
|
-
} catch (e) {
|
|
90
|
-
return ['joi']
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
86
|
+
|
|
94
87
|
/**
|
|
95
88
|
* Checks that response code is equal to the provided one
|
|
96
89
|
*
|
|
@@ -302,28 +295,28 @@ class JSONResponse extends Helper {
|
|
|
302
295
|
}
|
|
303
296
|
|
|
304
297
|
/**
|
|
305
|
-
* Validates JSON structure of response using [
|
|
306
|
-
* See [
|
|
298
|
+
* Validates JSON structure of response using [Zod library](https://zod.dev).
|
|
299
|
+
* See [Zod API](https://zod.dev/) for complete reference on usage.
|
|
307
300
|
*
|
|
308
|
-
* Use pre-initialized
|
|
301
|
+
* Use pre-initialized Zod instance by passing function callback:
|
|
309
302
|
*
|
|
310
303
|
* ```js
|
|
311
304
|
* // response.data is { name: 'jon', id: 1 }
|
|
312
305
|
*
|
|
313
|
-
* I.seeResponseMatchesJsonSchema(
|
|
314
|
-
* return
|
|
315
|
-
* name:
|
|
316
|
-
* id:
|
|
306
|
+
* I.seeResponseMatchesJsonSchema(z => {
|
|
307
|
+
* return z.object({
|
|
308
|
+
* name: z.string(),
|
|
309
|
+
* id: z.number()
|
|
317
310
|
* })
|
|
318
311
|
* });
|
|
319
312
|
*
|
|
320
313
|
* // or pass a valid schema
|
|
321
|
-
*
|
|
314
|
+
* import { z } from 'zod';
|
|
322
315
|
*
|
|
323
|
-
* I.seeResponseMatchesJsonSchema(
|
|
324
|
-
* name:
|
|
325
|
-
* id:
|
|
326
|
-
* });
|
|
316
|
+
* I.seeResponseMatchesJsonSchema(z.object({
|
|
317
|
+
* name: z.string(),
|
|
318
|
+
* id: z.number()
|
|
319
|
+
* }));
|
|
327
320
|
* ```
|
|
328
321
|
*
|
|
329
322
|
* @param {any} fnOrSchema
|
|
@@ -332,14 +325,17 @@ class JSONResponse extends Helper {
|
|
|
332
325
|
this._checkResponseReady()
|
|
333
326
|
let schema = fnOrSchema
|
|
334
327
|
if (typeof fnOrSchema === 'function') {
|
|
335
|
-
schema = fnOrSchema(
|
|
328
|
+
schema = fnOrSchema(z)
|
|
336
329
|
const body = fnOrSchema.toString()
|
|
337
330
|
fnOrSchema.toString = () => `${body.split('\n')[1]}...`
|
|
338
331
|
}
|
|
339
|
-
if (!schema) throw new Error('Empty
|
|
340
|
-
if (!
|
|
341
|
-
schema.toString = () => schema.
|
|
342
|
-
|
|
332
|
+
if (!schema) throw new Error('Empty Zod schema provided, see https://zod.dev/ for details')
|
|
333
|
+
if (!(schema instanceof z.ZodType)) throw new Error('Invalid Zod schema provided, see https://zod.dev/ for details')
|
|
334
|
+
schema.toString = () => schema._def.description || JSON.stringify(schema._def)
|
|
335
|
+
const result = schema.parse(this.response.data)
|
|
336
|
+
if (!result) {
|
|
337
|
+
throw new Error('Schema validation failed')
|
|
338
|
+
}
|
|
343
339
|
}
|
|
344
340
|
|
|
345
341
|
_checkResponseReady() {
|
|
@@ -376,4 +372,4 @@ class JSONResponse extends Helper {
|
|
|
376
372
|
}
|
|
377
373
|
}
|
|
378
374
|
|
|
379
|
-
|
|
375
|
+
export { JSONResponse as default }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
let currentTest
|
|
2
2
|
let currentSuite
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import Helper from '@codeceptjs/helper'
|
|
5
|
+
import { createRequire } from 'module'
|
|
6
|
+
import { clearString } from '../utils.js'
|
|
7
|
+
import { testToFileName } from '../mocha/test.js'
|
|
7
8
|
|
|
8
9
|
class Mochawesome extends Helper {
|
|
9
10
|
constructor(config) {
|
|
@@ -15,6 +16,8 @@ class Mochawesome extends Helper {
|
|
|
15
16
|
disableScreenshots: false,
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
// ESM-compatible require for CommonJS module
|
|
20
|
+
const require = createRequire(import.meta.url)
|
|
18
21
|
this._addContext = require('mochawesome/addContext')
|
|
19
22
|
|
|
20
23
|
this._createConfig(config)
|
|
@@ -90,4 +93,4 @@ class Mochawesome extends Helper {
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
export default Mochawesome
|