codeceptjs 4.0.0-beta.1 → 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 +133 -120
- package/bin/codecept.js +107 -96
- package/bin/test-server.js +64 -0
- package/docs/webapi/clearCookie.mustache +1 -1
- package/docs/webapi/click.mustache +5 -1
- package/lib/actor.js +71 -103
- package/lib/ai.js +159 -188
- package/lib/assert/empty.js +22 -24
- package/lib/assert/equal.js +30 -37
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +43 -48
- package/lib/assert/throws.js +11 -11
- package/lib/assert/truth.js +22 -22
- package/lib/assert.js +20 -18
- package/lib/codecept.js +238 -162
- package/lib/colorUtils.js +50 -52
- package/lib/command/check.js +206 -0
- package/lib/command/configMigrate.js +56 -51
- package/lib/command/definitions.js +96 -109
- package/lib/command/dryRun.js +77 -79
- package/lib/command/generate.js +234 -194
- package/lib/command/gherkin/init.js +42 -33
- package/lib/command/gherkin/snippets.js +76 -74
- package/lib/command/gherkin/steps.js +20 -17
- package/lib/command/info.js +74 -38
- package/lib/command/init.js +300 -290
- package/lib/command/interactive.js +41 -32
- package/lib/command/list.js +28 -27
- package/lib/command/run-multiple/chunk.js +51 -48
- package/lib/command/run-multiple/collection.js +5 -5
- package/lib/command/run-multiple/run.js +5 -1
- package/lib/command/run-multiple.js +97 -97
- package/lib/command/run-rerun.js +19 -25
- package/lib/command/run-workers.js +68 -92
- package/lib/command/run.js +39 -27
- package/lib/command/utils.js +80 -64
- package/lib/command/workers/runTests.js +388 -226
- package/lib/config.js +124 -50
- package/lib/container.js +751 -260
- package/lib/data/context.js +60 -61
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +32 -32
- package/lib/data/table.js +22 -22
- package/lib/effects.js +307 -0
- package/lib/element/WebElement.js +327 -0
- package/lib/els.js +160 -0
- package/lib/event.js +173 -163
- package/lib/globals.js +141 -0
- package/lib/heal.js +89 -85
- package/lib/helper/AI.js +131 -41
- package/lib/helper/ApiDataFactory.js +107 -75
- package/lib/helper/Appium.js +542 -404
- package/lib/helper/FileSystem.js +100 -79
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +52 -52
- package/lib/helper/JSONResponse.js +126 -88
- package/lib/helper/Mochawesome.js +54 -29
- package/lib/helper/Playwright.js +2547 -1316
- package/lib/helper/Puppeteer.js +1578 -1181
- package/lib/helper/REST.js +209 -68
- package/lib/helper/WebDriver.js +1482 -1342
- 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 +17 -8
- package/lib/helper/extras/PlaywrightRestartOpts.js +25 -11
- package/lib/helper/extras/Popup.js +22 -22
- package/lib/helper/extras/React.js +27 -28
- package/lib/helper/network/actions.js +36 -42
- package/lib/helper/network/utils.js +78 -84
- package/lib/helper/scripts/blurElement.js +5 -5
- package/lib/helper/scripts/focusElement.js +5 -5
- package/lib/helper/scripts/highlightElement.js +8 -8
- package/lib/helper/scripts/isElementClickable.js +34 -34
- package/lib/helper.js +2 -3
- package/lib/history.js +23 -19
- package/lib/hooks.js +8 -8
- package/lib/html.js +94 -104
- package/lib/index.js +38 -27
- package/lib/listener/config.js +30 -23
- package/lib/listener/emptyRun.js +54 -0
- package/lib/listener/enhancedGlobalRetry.js +110 -0
- package/lib/listener/exit.js +16 -18
- package/lib/listener/globalRetry.js +70 -0
- package/lib/listener/globalTimeout.js +181 -0
- package/lib/listener/helpers.js +76 -51
- package/lib/listener/mocha.js +10 -11
- package/lib/listener/result.js +11 -0
- package/lib/listener/retryEnhancer.js +85 -0
- package/lib/listener/steps.js +71 -59
- package/lib/listener/store.js +20 -0
- package/lib/locator.js +214 -197
- package/lib/mocha/asyncWrapper.js +274 -0
- package/lib/mocha/bdd.js +167 -0
- package/lib/mocha/cli.js +341 -0
- package/lib/mocha/factory.js +163 -0
- package/lib/mocha/featureConfig.js +89 -0
- package/lib/mocha/gherkin.js +231 -0
- package/lib/mocha/hooks.js +121 -0
- package/lib/mocha/index.js +21 -0
- package/lib/mocha/inject.js +46 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +58 -34
- package/lib/mocha/suite.js +89 -0
- package/lib/mocha/test.js +184 -0
- package/lib/mocha/types.d.ts +42 -0
- package/lib/mocha/ui.js +242 -0
- package/lib/output.js +141 -71
- package/lib/parser.js +47 -44
- package/lib/pause.js +173 -145
- package/lib/plugin/analyze.js +403 -0
- package/lib/plugin/{autoLogin.js → auth.js} +178 -79
- package/lib/plugin/autoDelay.js +36 -40
- package/lib/plugin/coverage.js +131 -78
- package/lib/plugin/customLocator.js +22 -21
- package/lib/plugin/customReporter.js +53 -0
- package/lib/plugin/enhancedRetryFailedStep.js +99 -0
- package/lib/plugin/heal.js +101 -110
- package/lib/plugin/htmlReporter.js +3648 -0
- package/lib/plugin/pageInfo.js +140 -0
- package/lib/plugin/pauseOnFail.js +12 -11
- package/lib/plugin/retryFailedStep.js +82 -47
- package/lib/plugin/screenshotOnFail.js +111 -92
- package/lib/plugin/stepByStepReport.js +159 -101
- package/lib/plugin/stepTimeout.js +20 -25
- package/lib/plugin/subtitles.js +38 -38
- package/lib/recorder.js +193 -130
- package/lib/rerun.js +94 -49
- package/lib/result.js +238 -0
- package/lib/retryCoordinator.js +207 -0
- package/lib/secret.js +20 -18
- package/lib/session.js +95 -89
- package/lib/step/base.js +239 -0
- package/lib/step/comment.js +10 -0
- package/lib/step/config.js +50 -0
- package/lib/step/func.js +46 -0
- package/lib/step/helper.js +50 -0
- package/lib/step/meta.js +99 -0
- package/lib/step/record.js +74 -0
- package/lib/step/retry.js +11 -0
- package/lib/step/section.js +55 -0
- package/lib/step.js +18 -329
- package/lib/steps.js +54 -0
- package/lib/store.js +38 -7
- package/lib/template/heal.js +3 -12
- 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 +334 -0
- package/lib/timeout.js +60 -0
- package/lib/transform.js +8 -8
- package/lib/translation.js +34 -21
- package/lib/utils/mask_data.js +47 -0
- package/lib/utils.js +411 -228
- package/lib/workerStorage.js +37 -34
- package/lib/workers.js +532 -296
- package/package.json +115 -95
- package/translations/de-DE.js +5 -3
- package/translations/fr-FR.js +5 -4
- package/translations/index.js +22 -12
- package/translations/it-IT.js +4 -3
- package/translations/ja-JP.js +4 -3
- package/translations/nl-NL.js +76 -0
- package/translations/pl-PL.js +4 -3
- package/translations/pt-BR.js +4 -3
- package/translations/ru-RU.js +4 -3
- package/translations/utils.js +10 -0
- package/translations/zh-CN.js +4 -3
- package/translations/zh-TW.js +4 -3
- package/typings/index.d.ts +546 -185
- package/typings/promiseBasedTypes.d.ts +150 -879
- package/typings/types.d.ts +547 -996
- package/lib/cli.js +0 -249
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
- package/lib/helper/ExpectHelper.js +0 -399
- package/lib/helper/MockServer.js +0 -223
- package/lib/helper/Nightmare.js +0 -1411
- package/lib/helper/Protractor.js +0 -1835
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/helper/TestCafe.js +0 -1410
- package/lib/helper/clientscripts/nightmare.js +0 -213
- package/lib/helper/testcafe/testControllerHolder.js +0 -42
- package/lib/helper/testcafe/testcafe-utils.js +0 -63
- package/lib/interfaces/bdd.js +0 -98
- package/lib/interfaces/featureConfig.js +0 -69
- package/lib/interfaces/gherkin.js +0 -195
- package/lib/listener/artifacts.js +0 -19
- package/lib/listener/retry.js +0 -68
- package/lib/listener/timeout.js +0 -109
- package/lib/mochaFactory.js +0 -110
- package/lib/plugin/allure.js +0 -15
- package/lib/plugin/commentStep.js +0 -136
- package/lib/plugin/debugErrors.js +0 -67
- package/lib/plugin/eachElement.js +0 -127
- package/lib/plugin/fakerTransform.js +0 -49
- package/lib/plugin/retryTo.js +0 -121
- package/lib/plugin/selenoid.js +0 -371
- package/lib/plugin/standardActingHelpers.js +0 -9
- package/lib/plugin/tryTo.js +0 -105
- package/lib/plugin/wdio.js +0 -246
- package/lib/scenario.js +0 -222
- package/lib/ui.js +0 -238
- package/lib/within.js +0 -70
package/lib/assert/include.js
CHANGED
|
@@ -1,79 +1,74 @@
|
|
|
1
|
-
import Assertion from '../assert.js'
|
|
2
|
-
import AssertionFailedError from './error.js'
|
|
3
|
-
import { template } from '../utils.js'
|
|
4
|
-
import
|
|
1
|
+
import Assertion from '../assert.js'
|
|
2
|
+
import AssertionFailedError from './error.js'
|
|
3
|
+
import { template } from '../utils.js'
|
|
4
|
+
import output from '../output.js'
|
|
5
5
|
|
|
6
|
-
const MAX_LINES = 10
|
|
6
|
+
const MAX_LINES = 10
|
|
7
7
|
|
|
8
8
|
class InclusionAssertion extends Assertion {
|
|
9
9
|
constructor(params) {
|
|
10
|
-
params.jar = params.jar || 'string'
|
|
10
|
+
params.jar = params.jar || 'string'
|
|
11
11
|
const comparator = function (needle, haystack) {
|
|
12
12
|
if (Array.isArray(haystack)) {
|
|
13
|
-
return haystack.filter(part => part.indexOf(needle) >= 0).length > 0
|
|
13
|
+
return haystack.filter(part => part.indexOf(needle) >= 0).length > 0
|
|
14
14
|
}
|
|
15
|
-
return haystack.indexOf(needle) >= 0
|
|
16
|
-
}
|
|
17
|
-
super(comparator, params)
|
|
18
|
-
this.params.type = 'to include'
|
|
15
|
+
return haystack.indexOf(needle) >= 0
|
|
16
|
+
}
|
|
17
|
+
super(comparator, params)
|
|
18
|
+
this.params.type = 'to include'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
getException() {
|
|
22
|
-
const params = this.params
|
|
23
|
-
params.jar = template(params.jar, params)
|
|
24
|
-
const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} {{type}} "{{needle}}"')
|
|
25
|
-
err.expected = params.needle
|
|
26
|
-
err.actual = params.haystack
|
|
22
|
+
const params = this.params
|
|
23
|
+
params.jar = template(params.jar, params)
|
|
24
|
+
const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} {{type}} "{{needle}}"')
|
|
25
|
+
err.expected = params.needle
|
|
26
|
+
err.actual = params.haystack
|
|
27
27
|
if (Array.isArray(this.params.haystack)) {
|
|
28
|
-
this.params.haystack = this.params.haystack.join('\n___(next element)___\n')
|
|
28
|
+
this.params.haystack = this.params.haystack.join('\n___(next element)___\n')
|
|
29
29
|
}
|
|
30
30
|
err.cliMessage = function () {
|
|
31
|
-
const msg = this.template
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
return err;
|
|
31
|
+
const msg = this.template.replace('{{jar}}', output.colors.bold('{{jar}}')).replace('{{needle}}', output.colors.bold('{{needle}}'))
|
|
32
|
+
return template(msg, this.params)
|
|
33
|
+
}
|
|
34
|
+
return err
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
getFailedAssertion() {
|
|
40
|
-
const err = this.getException()
|
|
41
|
-
const lines = this.params.haystack.split('\n')
|
|
38
|
+
const err = this.getException()
|
|
39
|
+
const lines = this.params.haystack.split('\n')
|
|
42
40
|
if (lines.length > MAX_LINES) {
|
|
43
|
-
const more = lines.length - MAX_LINES
|
|
44
|
-
err.actual = `${lines.slice(0, MAX_LINES).join('\n')}\n--( ${more} lines more )
|
|
41
|
+
const more = lines.length - MAX_LINES
|
|
42
|
+
err.actual = `${lines.slice(0, MAX_LINES).join('\n')}\n--( ${more} lines more )---`
|
|
45
43
|
}
|
|
46
|
-
return err
|
|
44
|
+
return err
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
getFailedNegation() {
|
|
50
|
-
this.params.type = 'not to include'
|
|
51
|
-
const err = this.getException()
|
|
52
|
-
const pattern = new RegExp(`^.*?\n?^.*?\n?^.*?${escapeRegExp(this.params.needle)}.*?$\n?.*$\n?.*$`, 'm')
|
|
53
|
-
const matched = this.params.haystack.match(pattern)
|
|
54
|
-
if (!matched) return err
|
|
55
|
-
err.actual = matched[0].replace(this.params.needle, output.
|
|
56
|
-
err.actual = `------\n${err.actual}\n
|
|
57
|
-
return err
|
|
48
|
+
this.params.type = 'not to include'
|
|
49
|
+
const err = this.getException()
|
|
50
|
+
const pattern = new RegExp(`^.*?\n?^.*?\n?^.*?${escapeRegExp(this.params.needle)}.*?$\n?.*$\n?.*$`, 'm')
|
|
51
|
+
const matched = this.params.haystack.match(pattern)
|
|
52
|
+
if (!matched) return err
|
|
53
|
+
err.actual = matched[0].replace(this.params.needle, output.colors.bold(this.params.needle))
|
|
54
|
+
err.actual = `------\n${err.actual}\n------`
|
|
55
|
+
return err
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
addAssertParams() {
|
|
61
|
-
this.params.needle = arguments[0]
|
|
62
|
-
this.params.haystack = arguments[1]
|
|
63
|
-
this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : ''
|
|
59
|
+
this.params.needle = arguments[0]
|
|
60
|
+
this.params.haystack = arguments[1]
|
|
61
|
+
this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : ''
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
export { InclusionAssertion as Assertion }
|
|
68
|
-
export
|
|
69
|
-
needleType = needleType || 'string'
|
|
70
|
-
return new InclusionAssertion({ jar: needleType })
|
|
65
|
+
export { InclusionAssertion as Assertion }
|
|
66
|
+
export const includes = needleType => {
|
|
67
|
+
needleType = needleType || 'string'
|
|
68
|
+
return new InclusionAssertion({ jar: needleType })
|
|
71
69
|
}
|
|
70
|
+
export const fileIncludes = file => new InclusionAssertion({ file, jar: 'file {{file}}' })
|
|
72
71
|
|
|
73
72
|
function escapeRegExp(str) {
|
|
74
|
-
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function fileIncludes(file) {
|
|
78
|
-
return new InclusionAssertion({ file, jar: 'file {{file}}' });
|
|
73
|
+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
|
|
79
74
|
}
|
package/lib/assert/throws.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
function errorThrown(actual, expected) {
|
|
2
|
-
if (!expected) return null
|
|
3
|
-
if (!actual) throw new Error(`Expected ${expected} error to be thrown`)
|
|
4
|
-
const msg = actual.inspect ? actual.inspect() : actual.toString()
|
|
2
|
+
if (!expected) return null
|
|
3
|
+
if (!actual) throw new Error(`Expected ${expected} error to be thrown`)
|
|
4
|
+
const msg = actual.inspect ? actual.inspect() : actual.toString()
|
|
5
5
|
if (expected instanceof RegExp) {
|
|
6
|
-
if (msg.match(expected)) return null
|
|
7
|
-
throw new Error(`Expected error to be thrown with message matching ${expected} while '${msg}' caught`)
|
|
6
|
+
if (msg.match(expected)) return null
|
|
7
|
+
throw new Error(`Expected error to be thrown with message matching ${expected} while '${msg}' caught`)
|
|
8
8
|
}
|
|
9
9
|
if (typeof expected === 'string') {
|
|
10
|
-
if (msg === expected) return null
|
|
11
|
-
throw new Error(`Expected error to be thrown with message ${expected} while '${msg}' caught`)
|
|
10
|
+
if (msg === expected) return null
|
|
11
|
+
throw new Error(`Expected error to be thrown with message ${expected} while '${msg}' caught`)
|
|
12
12
|
}
|
|
13
13
|
if (typeof expected === 'object') {
|
|
14
|
-
if (actual.constructor.name !== expected.constructor.name) throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`)
|
|
15
|
-
if (expected.message && expected.message !== msg) throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`)
|
|
14
|
+
if (actual.constructor.name !== expected.constructor.name) throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`)
|
|
15
|
+
if (expected.message && expected.message !== msg) throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`)
|
|
16
16
|
}
|
|
17
|
-
return null
|
|
17
|
+
return null
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default errorThrown
|
|
20
|
+
export default errorThrown
|
package/lib/assert/truth.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import Assertion from '../assert.js'
|
|
2
|
-
import AssertionFailedError from './error.js'
|
|
3
|
-
import { template } from '../utils.js'
|
|
4
|
-
import
|
|
1
|
+
import Assertion from '../assert.js'
|
|
2
|
+
import AssertionFailedError from './error.js'
|
|
3
|
+
import { template } from '../utils.js'
|
|
4
|
+
import output from '../output.js'
|
|
5
5
|
|
|
6
6
|
class TruthAssertion extends Assertion {
|
|
7
7
|
constructor(params) {
|
|
8
|
-
super(
|
|
8
|
+
super(value => {
|
|
9
9
|
if (Array.isArray(value)) {
|
|
10
|
-
return value.filter(val => !!val).length > 0
|
|
10
|
+
return value.filter(val => !!val).length > 0
|
|
11
11
|
}
|
|
12
|
-
return !!value
|
|
13
|
-
}, params)
|
|
14
|
-
this.params.type = this.params.type || 'to be true'
|
|
12
|
+
return !!value
|
|
13
|
+
}, params)
|
|
14
|
+
this.params.type = this.params.type || 'to be true'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
getException() {
|
|
18
|
-
const err = new AssertionFailedError(this.params, '{{customMessage}}expected {{subject}} {{type}}')
|
|
18
|
+
const err = new AssertionFailedError(this.params, '{{customMessage}}expected {{subject}} {{type}}')
|
|
19
19
|
err.cliMessage = () => {
|
|
20
|
-
const msg = err.template
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return err;
|
|
20
|
+
const msg = err.template.replace('{{subject}}', output.colors.bold('{{subject}}'))
|
|
21
|
+
return template(msg, this.params)
|
|
22
|
+
}
|
|
23
|
+
return err
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
addAssertParams() {
|
|
28
|
-
this.params.value = this.params.actual = arguments[0]
|
|
29
|
-
this.params.expected = true
|
|
30
|
-
this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : ''
|
|
27
|
+
this.params.value = this.params.actual = arguments[0]
|
|
28
|
+
this.params.expected = true
|
|
29
|
+
this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : ''
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
export { TruthAssertion as Assertion }
|
|
34
|
+
export const truth = (subject, type) => new TruthAssertion({ subject, type })
|
|
35
|
+
|
|
37
36
|
export default {
|
|
38
37
|
Assertion: TruthAssertion,
|
|
39
|
-
}
|
|
38
|
+
truth: (subject, type) => new TruthAssertion({ subject, type }),
|
|
39
|
+
}
|
package/lib/assert.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AssertionFailedError from './assert/error.js'
|
|
1
|
+
import AssertionFailedError from './assert/error.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Abstract assertion class introduced for more verbose and customizable messages.
|
|
@@ -20,11 +20,11 @@ import AssertionFailedError from './assert/error.js';
|
|
|
20
20
|
* to get more customizable exception messages.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
class Assertion {
|
|
24
24
|
constructor(comparator, params) {
|
|
25
|
-
this.comparator = comparator
|
|
26
|
-
this.params = params || {}
|
|
27
|
-
this.params.customMessage = ''
|
|
25
|
+
this.comparator = comparator
|
|
26
|
+
this.params = params || {}
|
|
27
|
+
this.params.customMessage = ''
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -32,10 +32,10 @@ export default class Assertion {
|
|
|
32
32
|
* Fails if comparator function with provided arguments returns false
|
|
33
33
|
*/
|
|
34
34
|
assert() {
|
|
35
|
-
this.addAssertParams.apply(this, arguments)
|
|
36
|
-
const result = this.comparator.apply(this.params, arguments)
|
|
37
|
-
if (result) return
|
|
38
|
-
throw this.getFailedAssertion()
|
|
35
|
+
this.addAssertParams.apply(this, arguments)
|
|
36
|
+
const result = this.comparator.apply(this.params, arguments)
|
|
37
|
+
if (result) return // should increase global assertion counter
|
|
38
|
+
throw this.getFailedAssertion()
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -43,10 +43,10 @@ export default class Assertion {
|
|
|
43
43
|
* Fails if comparator function with provided arguments returns true
|
|
44
44
|
*/
|
|
45
45
|
negate() {
|
|
46
|
-
this.addAssertParams.apply(this, arguments)
|
|
47
|
-
const result = this.comparator.apply(this.params, arguments)
|
|
48
|
-
if (!result) return
|
|
49
|
-
throw this.getFailedNegation()
|
|
46
|
+
this.addAssertParams.apply(this, arguments)
|
|
47
|
+
const result = this.comparator.apply(this.params, arguments)
|
|
48
|
+
if (!result) return // should increase global assertion counter
|
|
49
|
+
throw this.getFailedNegation()
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -55,16 +55,18 @@ export default class Assertion {
|
|
|
55
55
|
addAssertParams() {}
|
|
56
56
|
|
|
57
57
|
getException() {
|
|
58
|
-
return new AssertionFailedError(this.params, '')
|
|
58
|
+
return new AssertionFailedError(this.params, '')
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
getFailedNegation() {
|
|
62
|
-
const err = this.getException()
|
|
63
|
-
err.params.type = `not ${err.params.type}
|
|
64
|
-
return err
|
|
62
|
+
const err = this.getException()
|
|
63
|
+
err.params.type = `not ${err.params.type}`
|
|
64
|
+
return err
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
getFailedAssertion() {
|
|
68
|
-
return this.getException()
|
|
68
|
+
return this.getException()
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
export default Assertion
|