testcafe 1.13.0 → 1.14.2
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/CHANGELOG.md +88 -10
- package/LICENSE +21 -21
- package/README.md +52 -48
- package/bin/testcafe-with-v8-flag-filter.js +0 -0
- package/lib/api/exportable-lib/index.js +50 -50
- package/lib/api/request-hooks/assert-type.js +7 -7
- package/lib/api/request-hooks/hook-method-names.js +11 -0
- package/lib/api/request-hooks/hook.js +33 -39
- package/lib/api/request-hooks/interfaces.js +3 -3
- package/lib/api/request-hooks/request-logger.js +113 -111
- package/lib/api/request-hooks/request-mock/create-request-mock.js +12 -0
- package/lib/api/request-hooks/request-mock/index.js +46 -0
- package/lib/api/request-hooks/request-mock.js +47 -48
- package/lib/api/structure/base-unit.js +11 -11
- package/lib/api/structure/fixture.js +75 -75
- package/lib/api/structure/interfaces.js +2 -2
- package/lib/api/structure/test-file.js +31 -31
- package/lib/api/structure/test-timeout.js +9 -9
- package/lib/api/structure/test.js +85 -85
- package/lib/api/structure/testing-unit.js +89 -89
- package/lib/api/structure/unit-type.js +9 -9
- package/lib/api/test-controller/assertion.js +88 -88
- package/lib/api/test-controller/execution-context.js +82 -82
- package/lib/api/test-controller/index.js +359 -319
- package/lib/api/test-controller/proxy.js +28 -28
- package/lib/api/test-page-url.js +60 -60
- package/lib/api/test-run-tracker.js +68 -68
- package/lib/api/wrap-test-function.js +49 -49
- package/lib/assertions/executor.js +74 -74
- package/lib/assertions/get-fn.js +46 -46
- package/lib/assertions/type.js +20 -20
- package/lib/assets/content-types.js +9 -9
- package/lib/assets/injectables.js +18 -18
- package/lib/browser/connection/command.js +10 -10
- package/lib/browser/connection/error-hints.js +9 -9
- package/lib/browser/connection/gateway.js +159 -159
- package/lib/browser/connection/get-hints.js +33 -33
- package/lib/browser/connection/heartbeat-status.js +8 -8
- package/lib/browser/connection/index.js +328 -328
- package/lib/browser/connection/remotes-queue.js +46 -46
- package/lib/browser/connection/service-routes.js +12 -12
- package/lib/browser/connection/status.js +12 -12
- package/lib/browser/interfaces.js +2 -2
- package/lib/browser/provider/built-in/dedicated/base.js +80 -80
- package/lib/browser/provider/built-in/dedicated/chrome/browser-client.js +204 -204
- package/lib/browser/provider/built-in/dedicated/chrome/build-chrome-args.js +17 -17
- package/lib/browser/provider/built-in/dedicated/chrome/config.js +110 -110
- package/lib/browser/provider/built-in/dedicated/chrome/create-temp-profile.js +45 -45
- package/lib/browser/provider/built-in/dedicated/chrome/elapsed-upperbounds.js +15 -15
- package/lib/browser/provider/built-in/dedicated/chrome/index.js +102 -102
- package/lib/browser/provider/built-in/dedicated/chrome/interfaces.js +2 -2
- package/lib/browser/provider/built-in/dedicated/chrome/local-chrome.js +24 -24
- package/lib/browser/provider/built-in/dedicated/chrome/runtime-info.js +29 -29
- package/lib/browser/provider/built-in/dedicated/edge/index.js +10 -10
- package/lib/browser/provider/built-in/dedicated/edge/runtime-info.js +29 -29
- package/lib/browser/provider/built-in/dedicated/firefox/config.js +33 -33
- package/lib/browser/provider/built-in/dedicated/firefox/create-temp-profile.js +78 -78
- package/lib/browser/provider/built-in/dedicated/firefox/index.js +73 -73
- package/lib/browser/provider/built-in/dedicated/firefox/local-firefox.js +36 -36
- package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/commands.js +13 -13
- package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/index.js +200 -200
- package/lib/browser/provider/built-in/dedicated/firefox/runtime-info.js +17 -17
- package/lib/browser/provider/built-in/index.js +21 -21
- package/lib/browser/provider/built-in/locally-installed.js +30 -30
- package/lib/browser/provider/built-in/path.js +47 -47
- package/lib/browser/provider/built-in/remote.js +58 -58
- package/lib/browser/provider/index.js +303 -303
- package/lib/browser/provider/parse-provider-name.js +16 -16
- package/lib/browser/provider/plugin-host.js +121 -121
- package/lib/browser/provider/pool.js +115 -115
- package/lib/browser/provider/utils/argument-parsing.js +74 -74
- package/lib/browser/provider/utils/browser-starter.js +34 -34
- package/lib/browser/provider/utils/client-functions.js +24 -24
- package/lib/browser/provider/utils/get-maximized-headless-window-size.js +9 -9
- package/lib/cli/argument-parser.js +284 -279
- package/lib/cli/authentication-helper.js +35 -35
- package/lib/cli/cli.js +134 -134
- package/lib/cli/correct-browsers-and-sources.js +40 -40
- package/lib/cli/index.js +19 -19
- package/lib/cli/log.js +43 -43
- package/lib/cli/remotes-wizard.js +36 -36
- package/lib/cli/termination-handler.js +38 -38
- package/lib/client/automation/index.js +144 -46
- package/lib/client/automation/index.min.js +1 -1
- package/lib/client/browser/idle-page/index.html.mustache +35 -35
- package/lib/client/browser/idle-page/logo.svg +86 -86
- package/lib/client/browser/service-worker.js +4 -6
- package/lib/client/core/index.js +19 -13
- package/lib/client/core/index.min.js +1 -1
- package/lib/client/driver/index.js +1807 -451
- package/lib/client/driver/index.min.js +1 -1
- package/lib/client/driver/internal-properties.js +9 -9
- package/lib/client/test-run/iframe.js.mustache +17 -17
- package/lib/client/test-run/index.js.mustache +51 -51
- package/lib/client/ui/index.js +14 -12
- package/lib/client/ui/index.min.js +1 -1
- package/lib/client/ui/sprite.svg +42 -42
- package/lib/client-functions/builder-symbol.js +4 -4
- package/lib/client-functions/client-function-builder.js +156 -135
- package/lib/client-functions/replicator.js +61 -61
- package/lib/client-functions/return-single-prop-mode.js +8 -8
- package/lib/client-functions/selector-api-execution-mode.js +22 -0
- package/lib/client-functions/selectors/add-api.js +646 -588
- package/lib/client-functions/selectors/create-snapshot-methods.js +13 -13
- package/lib/client-functions/selectors/prepare-api-args.js +20 -20
- package/lib/client-functions/selectors/selector-attribute-filter.js +22 -22
- package/lib/client-functions/selectors/selector-builder.js +154 -150
- package/lib/client-functions/selectors/selector-text-filter.js +43 -43
- package/lib/client-functions/selectors/snapshot-properties.js +48 -48
- package/lib/client-functions/types.js +18 -18
- package/lib/compiler/babel/format-babel-produced-code.js +10 -10
- package/lib/compiler/babel/get-base-babel-options.js +11 -11
- package/lib/compiler/babel/load-libs.js +64 -62
- package/lib/compiler/babel/preset-stage-2.js +19 -19
- package/lib/compiler/compile-client-function.js +73 -73
- package/lib/compiler/compilers.js +33 -33
- package/lib/compiler/index.js +92 -92
- package/lib/compiler/interfaces.js +2 -2
- package/lib/compiler/test-file/api-based.js +146 -146
- package/lib/compiler/test-file/base.js +36 -36
- package/lib/compiler/test-file/exportble-lib-path.js +5 -5
- package/lib/compiler/test-file/formats/coffeescript/compiler.js +38 -38
- package/lib/compiler/test-file/formats/coffeescript/get-test-list.js +29 -29
- package/lib/compiler/test-file/formats/es-next/compiler.js +43 -43
- package/lib/compiler/test-file/formats/es-next/get-test-list.js +166 -166
- package/lib/compiler/test-file/formats/es-next/is-flow-code.js +7 -7
- package/lib/compiler/test-file/formats/raw.js +85 -85
- package/lib/compiler/test-file/formats/typescript/compiler.js +135 -135
- package/lib/compiler/test-file/formats/typescript/get-test-list.js +185 -185
- package/lib/compiler/test-file/test-file-parser-base.js +214 -214
- package/lib/configuration/configuration-base.js +165 -165
- package/lib/configuration/constants.js +9 -9
- package/lib/configuration/customizable-compilers.js +7 -7
- package/lib/configuration/default-values.js +51 -51
- package/lib/configuration/interfaces.js +3 -3
- package/lib/configuration/option-names.js +53 -53
- package/lib/configuration/option-source.js +9 -9
- package/lib/configuration/option.js +14 -14
- package/lib/configuration/quarantine-option-names.js +10 -0
- package/lib/configuration/run-option-names.js +26 -26
- package/lib/configuration/screenshot-option-names.js +10 -10
- package/lib/configuration/testcafe-configuration.js +164 -165
- package/lib/configuration/types.js +2 -2
- package/lib/configuration/typescript-configuration.js +62 -62
- package/lib/custom-client-scripts/assert-type.js +7 -7
- package/lib/custom-client-scripts/client-script-init.js +3 -3
- package/lib/custom-client-scripts/client-script.js +107 -108
- package/lib/custom-client-scripts/get-code.js +11 -11
- package/lib/custom-client-scripts/get-url.js +6 -6
- package/lib/custom-client-scripts/load.js +15 -15
- package/lib/custom-client-scripts/problematic-scripts.js +2 -2
- package/lib/custom-client-scripts/routing.js +36 -36
- package/lib/custom-client-scripts/utils.js +60 -60
- package/lib/embedding-utils.js +83 -83
- package/lib/errors/create-stack-filter.js +18 -18
- package/lib/errors/error-list.js +26 -26
- package/lib/errors/get-callsite.js +31 -31
- package/lib/errors/internal-modules-prefix.js +8 -8
- package/lib/errors/is-internal-stack-frame.js +46 -46
- package/lib/errors/process-test-fn-error.js +37 -37
- package/lib/errors/runtime/index.js +123 -123
- package/lib/errors/runtime/templates.js +116 -114
- package/lib/errors/runtime/type-assertions.js +112 -112
- package/lib/errors/stack-cleaning-hook.js +64 -64
- package/lib/errors/test-run/formattable-adapter.js +59 -59
- package/lib/errors/test-run/index.js +302 -302
- package/lib/errors/test-run/render-error-template.js +31 -31
- package/lib/errors/test-run/templates.js +93 -95
- package/lib/errors/test-run/utils.js +90 -85
- package/lib/errors/types.js +157 -155
- package/lib/index.js +81 -81
- package/lib/live/bootstrapper.js +44 -44
- package/lib/live/controller.js +107 -107
- package/lib/live/file-watcher/index.js +67 -67
- package/lib/live/file-watcher/modules-graph.js +58 -58
- package/lib/live/keyboard-observer.js +76 -76
- package/lib/live/logger/index.js +64 -64
- package/lib/live/test-run-controller.js +96 -96
- package/lib/live/test-run-state.js +6 -6
- package/lib/live/test-run.js +56 -56
- package/lib/live/test-runner.js +168 -168
- package/lib/load-assets.js +29 -29
- package/lib/notifications/add-rendered-warning.js +16 -16
- package/lib/notifications/debug-logger.js +78 -78
- package/lib/notifications/deprecated.js +24 -24
- package/lib/notifications/information-message.js +12 -12
- package/lib/notifications/warning-log.js +32 -31
- package/lib/notifications/warning-message.js +48 -48
- package/lib/reporter/command/command-formatter.js +120 -109
- package/lib/reporter/command/format-command.js +8 -8
- package/lib/reporter/command/interfaces.js +2 -2
- package/lib/reporter/index.js +319 -314
- package/lib/reporter/interfaces.js +2 -2
- package/lib/reporter/plugin-host.js +136 -137
- package/lib/reporter/plugin-methods.js +12 -12
- package/lib/role/index.js +74 -74
- package/lib/role/marker-symbol.js +7 -7
- package/lib/role/phase.js +9 -9
- package/lib/runner/bootstrapper.js +272 -272
- package/lib/runner/browser-job-result.js +9 -9
- package/lib/runner/browser-job.js +153 -123
- package/lib/runner/browser-set.js +114 -114
- package/lib/runner/fixture-hook-controller.js +85 -85
- package/lib/runner/index.js +450 -442
- package/lib/runner/interfaces.js +3 -3
- package/lib/runner/reporter-stream-controller.js +28 -28
- package/lib/runner/task/index.js +152 -133
- package/lib/runner/task/phase.js +9 -9
- package/lib/runner/test-run-controller.js +166 -185
- package/lib/runner/tested-app.js +73 -72
- package/lib/screenshots/capturer.js +141 -141
- package/lib/screenshots/constants.js +11 -11
- package/lib/screenshots/crop.js +111 -111
- package/lib/screenshots/default-extension.js +4 -4
- package/lib/screenshots/index.js +67 -67
- package/lib/screenshots/utils.js +39 -39
- package/lib/services/compiler/host.js +190 -106
- package/lib/services/compiler/io.js +9 -9
- package/lib/services/compiler/protocol.js +17 -16
- package/lib/services/compiler/service.js +225 -106
- package/lib/services/compiler/test-run-proxy.js +111 -73
- package/lib/services/interfaces.js +3 -0
- package/lib/services/process-title.js +8 -8
- package/lib/services/serialization/prepare-options.js +17 -17
- package/lib/services/serialization/replicator/create-replicator.js +27 -0
- package/lib/services/serialization/replicator/custom-error-transform.js +28 -0
- package/lib/services/serialization/test-structure.js +93 -77
- package/lib/services/utils/ipc/interfaces.js +30 -30
- package/lib/services/utils/ipc/io.js +108 -108
- package/lib/services/utils/ipc/message.js +76 -73
- package/lib/services/utils/ipc/packet.js +55 -55
- package/lib/services/utils/ipc/proxy.js +110 -118
- package/lib/services/utils/ipc/transport.js +64 -64
- package/lib/shared/errors/index.js +382 -382
- package/lib/shared/node-modules-folder-name.js +4 -4
- package/lib/test-run/bookmark.js +90 -90
- package/lib/test-run/browser-console-messages.js +73 -73
- package/lib/test-run/browser-manipulation-queue.js +92 -92
- package/lib/test-run/client-messages.js +9 -9
- package/lib/test-run/commands/actions.js +486 -425
- package/lib/test-run/commands/assertion.js +45 -45
- package/lib/test-run/commands/base.js +14 -14
- package/lib/test-run/commands/browser-manipulation.js +95 -95
- package/lib/test-run/commands/from-object.js +82 -82
- package/lib/test-run/commands/observation.js +61 -61
- package/lib/test-run/commands/options.js +231 -215
- package/lib/test-run/commands/service.js +54 -48
- package/lib/test-run/commands/type.js +65 -60
- package/lib/test-run/commands/utils.js +87 -87
- package/lib/test-run/commands/validations/argument.js +90 -90
- package/lib/test-run/commands/validations/factories.js +47 -47
- package/lib/test-run/commands/validations/initializers.js +44 -44
- package/lib/test-run/debug-log.js +32 -32
- package/lib/test-run/execute-js-expression.js +74 -74
- package/lib/test-run/index.js +823 -752
- package/lib/test-run/marker-symbol.js +7 -7
- package/lib/test-run/observed-callsites-storage.js +17 -17
- package/lib/test-run/phase.js +16 -16
- package/lib/test-run/session-controller.js +104 -104
- package/lib/testcafe.js +119 -114
- package/lib/utils/assignable.js +39 -39
- package/lib/utils/async-event-emitter.js +28 -28
- package/lib/utils/async-queue.js +14 -14
- package/lib/utils/browser-connection-timeouts.js +19 -19
- package/lib/utils/callsite.js +17 -17
- package/lib/utils/check-file-path.js +31 -31
- package/lib/utils/check-url.js +51 -51
- package/lib/utils/convert-to-best-fit-type.js +16 -16
- package/lib/utils/correct-file-path.js +21 -21
- package/lib/utils/define-lazy-property.js +13 -13
- package/lib/utils/delay.js +6 -6
- package/lib/utils/delegated-api.js +44 -44
- package/lib/utils/detect-display.js +6 -6
- package/lib/utils/detect-ffmpeg.js +44 -44
- package/lib/utils/diff/colors.js +29 -29
- package/lib/utils/diff/index.js +53 -53
- package/lib/utils/diff/util.js +24 -22
- package/lib/utils/diff.js +29 -29
- package/lib/utils/escape-user-agent.js +10 -10
- package/lib/utils/flag-list.js +17 -17
- package/lib/utils/get-any-key.js +8 -8
- package/lib/utils/get-browser.js +8 -8
- package/lib/utils/get-common-path.js +34 -34
- package/lib/utils/get-filter-fn.js +40 -40
- package/lib/utils/get-options/base.js +36 -36
- package/lib/utils/get-options/compiler.js +33 -33
- package/lib/utils/get-options/grep.js +15 -15
- package/lib/utils/get-options/index.js +21 -19
- package/lib/utils/get-options/meta.js +22 -22
- package/lib/utils/get-options/quarantine.js +92 -0
- package/lib/utils/get-options/screenshot.js +17 -17
- package/lib/utils/get-options/ssl.js +45 -45
- package/lib/utils/get-options/video.js +10 -10
- package/lib/utils/get-viewport-width.js +18 -18
- package/lib/utils/guard-time-execution.js +10 -10
- package/lib/utils/handle-errors.js +74 -74
- package/lib/utils/handle-tag-args.js +8 -8
- package/lib/utils/http.js +30 -30
- package/lib/utils/is-localhost.js +11 -11
- package/lib/utils/is-password-input.js +11 -0
- package/lib/utils/is-repl.js +12 -0
- package/lib/utils/is-window-in-iframe.js +6 -6
- package/lib/utils/limit-number.js +10 -10
- package/lib/utils/make-reg-exp.js +7 -7
- package/lib/utils/moment-loader.js +20 -20
- package/lib/utils/parse-file-list.js +71 -71
- package/lib/utils/parse-user-agent.js +55 -55
- package/lib/utils/path-pattern.js +114 -114
- package/lib/utils/prepare-reporters.js +30 -30
- package/lib/utils/prerender-callsite.js +18 -18
- package/lib/utils/process.js +119 -119
- package/lib/utils/promisified-functions.js +46 -46
- package/lib/utils/re-executable-promise.js +39 -39
- package/lib/utils/render-callsite-sync.js +29 -29
- package/lib/utils/render-template.js +10 -10
- package/lib/utils/reporter.js +30 -30
- package/lib/utils/resolve-path-relatively-cwd.js +7 -7
- package/lib/utils/string.js +105 -105
- package/lib/utils/temp-directory/cleanup-process/commands.js +7 -7
- package/lib/utils/temp-directory/cleanup-process/index.js +143 -143
- package/lib/utils/temp-directory/cleanup-process/worker.js +58 -58
- package/lib/utils/temp-directory/index.js +87 -87
- package/lib/utils/temp-directory/lockfile.js +56 -56
- package/lib/utils/thennable.js +7 -7
- package/lib/utils/timer.js +15 -15
- package/lib/utils/to-posix-path.js +8 -8
- package/lib/utils/types.js +2 -2
- package/lib/video-recorder/interfaces.js +2 -2
- package/lib/video-recorder/process.js +126 -126
- package/lib/video-recorder/recorder.js +136 -136
- package/lib/video-recorder/test-run-video-recorder.js +69 -69
- package/lib/video-recorder/videos.js +37 -37
- package/package.json +7 -7
- package/ts-defs/index.d.ts +109 -17
- package/ts-defs/selectors.d.ts +95 -7
- package/ts-defs/testcafe-scripts.d.ts +96 -8
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BrowserConnectionError = exports.TimeoutError = exports.ReporterPluginError = exports.CompositeError = exports.ClientFunctionAPIError = exports.APIError = exports.TestCompilationError = exports.GeneralError = void 0;
|
|
7
|
-
const callsite_record_1 = require("callsite-record");
|
|
8
|
-
const templates_1 = __importDefault(require("./templates"));
|
|
9
|
-
const create_stack_filter_1 = __importDefault(require("../create-stack-filter"));
|
|
10
|
-
const get_callsite_1 = require("../get-callsite");
|
|
11
|
-
const render_template_1 = __importDefault(require("../../utils/render-template"));
|
|
12
|
-
const render_callsite_sync_1 = __importDefault(require("../../utils/render-callsite-sync"));
|
|
13
|
-
const types_1 = require("../types");
|
|
14
|
-
const ERROR_SEPARATOR = '\n\n';
|
|
15
|
-
class ProcessTemplateInstruction {
|
|
16
|
-
constructor(processFn) {
|
|
17
|
-
this.processFn = processFn;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// Errors
|
|
21
|
-
class GeneralError extends Error {
|
|
22
|
-
constructor(...args) {
|
|
23
|
-
const code = args.shift();
|
|
24
|
-
const template = templates_1.default[code];
|
|
25
|
-
super(render_template_1.default(template, ...args));
|
|
26
|
-
Object.assign(this, { code, data: args });
|
|
27
|
-
Error.captureStackTrace(this, GeneralError);
|
|
28
|
-
}
|
|
29
|
-
static isGeneralError(arg) {
|
|
30
|
-
return arg instanceof GeneralError;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.GeneralError = GeneralError;
|
|
34
|
-
class TestCompilationError extends Error {
|
|
35
|
-
constructor(originalError) {
|
|
36
|
-
const template = templates_1.default[types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError];
|
|
37
|
-
const errorMessage = originalError.toString();
|
|
38
|
-
super(render_template_1.default(template, errorMessage));
|
|
39
|
-
Object.assign(this, {
|
|
40
|
-
code: types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError,
|
|
41
|
-
data: [errorMessage]
|
|
42
|
-
});
|
|
43
|
-
// NOTE: stack includes message as well.
|
|
44
|
-
this.stack = render_template_1.default(template, originalError.stack);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.TestCompilationError = TestCompilationError;
|
|
48
|
-
class APIError extends Error {
|
|
49
|
-
constructor(methodName, code, ...args) {
|
|
50
|
-
let template = templates_1.default[code];
|
|
51
|
-
template = APIError._prepareTemplateAndArgsIfNecessary(template, args);
|
|
52
|
-
const rawMessage = render_template_1.default(template, ...args);
|
|
53
|
-
super(render_template_1.default(templates_1.default[types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError], rawMessage));
|
|
54
|
-
Object.assign(this, { code, data: args });
|
|
55
|
-
// NOTE: `rawMessage` is used in error substitution if it occurs in test run.
|
|
56
|
-
this.rawMessage = rawMessage;
|
|
57
|
-
this.callsite = get_callsite_1.getCallsiteForMethod(methodName);
|
|
58
|
-
// NOTE: We need property getters here because callsite can be replaced by an external code.
|
|
59
|
-
// See https://github.com/DevExpress/testcafe/blob/v1.0.0/src/compiler/test-file/formats/raw.js#L22
|
|
60
|
-
// Also we can't use an ES6 getter for the 'stack' property, because it will create a getter on the class prototype
|
|
61
|
-
// that cannot override the instance property created by the Error parent class.
|
|
62
|
-
Object.defineProperties(this, {
|
|
63
|
-
'stack': {
|
|
64
|
-
get: () => this._createStack(callsite_record_1.renderers.noColor)
|
|
65
|
-
},
|
|
66
|
-
'coloredStack': {
|
|
67
|
-
get: () => this._createStack(callsite_record_1.renderers.default)
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
_createStack(renderer) {
|
|
72
|
-
const renderedCallsite = render_callsite_sync_1.default(this.callsite, {
|
|
73
|
-
renderer: renderer,
|
|
74
|
-
stackFilter: create_stack_filter_1.default(Error.stackTraceLimit)
|
|
75
|
-
});
|
|
76
|
-
if (!renderedCallsite)
|
|
77
|
-
return this.message;
|
|
78
|
-
return this.message + ERROR_SEPARATOR + renderedCallsite;
|
|
79
|
-
}
|
|
80
|
-
static _prepareTemplateAndArgsIfNecessary(template, args) {
|
|
81
|
-
const lastArg = args.pop();
|
|
82
|
-
if (lastArg instanceof ProcessTemplateInstruction)
|
|
83
|
-
template = lastArg.processFn(template);
|
|
84
|
-
else
|
|
85
|
-
args.push(lastArg);
|
|
86
|
-
return template;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.APIError = APIError;
|
|
90
|
-
class ClientFunctionAPIError extends APIError {
|
|
91
|
-
constructor(methodName, instantiationCallsiteName, code, ...args) {
|
|
92
|
-
args.push(new ProcessTemplateInstruction(template => template.replace(/\{#instantiationCallsiteName\}/g, instantiationCallsiteName)));
|
|
93
|
-
super(methodName, code, ...args);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.ClientFunctionAPIError = ClientFunctionAPIError;
|
|
97
|
-
class CompositeError extends Error {
|
|
98
|
-
constructor(errors) {
|
|
99
|
-
super(errors.map(({ message }) => message).join(ERROR_SEPARATOR));
|
|
100
|
-
this.stack = errors.map(({ stack }) => stack).join(ERROR_SEPARATOR);
|
|
101
|
-
this.code = types_1.RUNTIME_ERRORS.compositeArgumentsError;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.CompositeError = CompositeError;
|
|
105
|
-
class ReporterPluginError extends GeneralError {
|
|
106
|
-
constructor({ name, method, originalError }) {
|
|
107
|
-
const code = types_1.RUNTIME_ERRORS.uncaughtErrorInReporter;
|
|
108
|
-
super(code, name, method, originalError.stack);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.ReporterPluginError = ReporterPluginError;
|
|
112
|
-
class TimeoutError extends GeneralError {
|
|
113
|
-
constructor() {
|
|
114
|
-
super(types_1.RUNTIME_ERRORS.timeLimitedPromiseTimeoutExpired);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.TimeoutError = TimeoutError;
|
|
118
|
-
class BrowserConnectionError extends GeneralError {
|
|
119
|
-
constructor(...args) {
|
|
120
|
-
super(types_1.RUNTIME_ERRORS.browserConnectionError, ...args);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.BrowserConnectionError = BrowserConnectionError;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BrowserConnectionError = exports.TimeoutError = exports.ReporterPluginError = exports.CompositeError = exports.ClientFunctionAPIError = exports.APIError = exports.TestCompilationError = exports.GeneralError = void 0;
|
|
7
|
+
const callsite_record_1 = require("callsite-record");
|
|
8
|
+
const templates_1 = __importDefault(require("./templates"));
|
|
9
|
+
const create_stack_filter_1 = __importDefault(require("../create-stack-filter"));
|
|
10
|
+
const get_callsite_1 = require("../get-callsite");
|
|
11
|
+
const render_template_1 = __importDefault(require("../../utils/render-template"));
|
|
12
|
+
const render_callsite_sync_1 = __importDefault(require("../../utils/render-callsite-sync"));
|
|
13
|
+
const types_1 = require("../types");
|
|
14
|
+
const ERROR_SEPARATOR = '\n\n';
|
|
15
|
+
class ProcessTemplateInstruction {
|
|
16
|
+
constructor(processFn) {
|
|
17
|
+
this.processFn = processFn;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Errors
|
|
21
|
+
class GeneralError extends Error {
|
|
22
|
+
constructor(...args) {
|
|
23
|
+
const code = args.shift();
|
|
24
|
+
const template = templates_1.default[code];
|
|
25
|
+
super(render_template_1.default(template, ...args));
|
|
26
|
+
Object.assign(this, { code, data: args });
|
|
27
|
+
Error.captureStackTrace(this, GeneralError);
|
|
28
|
+
}
|
|
29
|
+
static isGeneralError(arg) {
|
|
30
|
+
return arg instanceof GeneralError;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GeneralError = GeneralError;
|
|
34
|
+
class TestCompilationError extends Error {
|
|
35
|
+
constructor(originalError) {
|
|
36
|
+
const template = templates_1.default[types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError];
|
|
37
|
+
const errorMessage = originalError.toString();
|
|
38
|
+
super(render_template_1.default(template, errorMessage));
|
|
39
|
+
Object.assign(this, {
|
|
40
|
+
code: types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError,
|
|
41
|
+
data: [errorMessage]
|
|
42
|
+
});
|
|
43
|
+
// NOTE: stack includes message as well.
|
|
44
|
+
this.stack = render_template_1.default(template, originalError.stack);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.TestCompilationError = TestCompilationError;
|
|
48
|
+
class APIError extends Error {
|
|
49
|
+
constructor(methodName, code, ...args) {
|
|
50
|
+
let template = templates_1.default[code];
|
|
51
|
+
template = APIError._prepareTemplateAndArgsIfNecessary(template, args);
|
|
52
|
+
const rawMessage = render_template_1.default(template, ...args);
|
|
53
|
+
super(render_template_1.default(templates_1.default[types_1.RUNTIME_ERRORS.cannotPrepareTestsDueToError], rawMessage));
|
|
54
|
+
Object.assign(this, { code, data: args });
|
|
55
|
+
// NOTE: `rawMessage` is used in error substitution if it occurs in test run.
|
|
56
|
+
this.rawMessage = rawMessage;
|
|
57
|
+
this.callsite = get_callsite_1.getCallsiteForMethod(methodName);
|
|
58
|
+
// NOTE: We need property getters here because callsite can be replaced by an external code.
|
|
59
|
+
// See https://github.com/DevExpress/testcafe/blob/v1.0.0/src/compiler/test-file/formats/raw.js#L22
|
|
60
|
+
// Also we can't use an ES6 getter for the 'stack' property, because it will create a getter on the class prototype
|
|
61
|
+
// that cannot override the instance property created by the Error parent class.
|
|
62
|
+
Object.defineProperties(this, {
|
|
63
|
+
'stack': {
|
|
64
|
+
get: () => this._createStack(callsite_record_1.renderers.noColor)
|
|
65
|
+
},
|
|
66
|
+
'coloredStack': {
|
|
67
|
+
get: () => this._createStack(callsite_record_1.renderers.default)
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
_createStack(renderer) {
|
|
72
|
+
const renderedCallsite = render_callsite_sync_1.default(this.callsite, {
|
|
73
|
+
renderer: renderer,
|
|
74
|
+
stackFilter: create_stack_filter_1.default(Error.stackTraceLimit)
|
|
75
|
+
});
|
|
76
|
+
if (!renderedCallsite)
|
|
77
|
+
return this.message;
|
|
78
|
+
return this.message + ERROR_SEPARATOR + renderedCallsite;
|
|
79
|
+
}
|
|
80
|
+
static _prepareTemplateAndArgsIfNecessary(template, args) {
|
|
81
|
+
const lastArg = args.pop();
|
|
82
|
+
if (lastArg instanceof ProcessTemplateInstruction)
|
|
83
|
+
template = lastArg.processFn(template);
|
|
84
|
+
else
|
|
85
|
+
args.push(lastArg);
|
|
86
|
+
return template;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.APIError = APIError;
|
|
90
|
+
class ClientFunctionAPIError extends APIError {
|
|
91
|
+
constructor(methodName, instantiationCallsiteName, code, ...args) {
|
|
92
|
+
args.push(new ProcessTemplateInstruction(template => template.replace(/\{#instantiationCallsiteName\}/g, instantiationCallsiteName)));
|
|
93
|
+
super(methodName, code, ...args);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.ClientFunctionAPIError = ClientFunctionAPIError;
|
|
97
|
+
class CompositeError extends Error {
|
|
98
|
+
constructor(errors) {
|
|
99
|
+
super(errors.map(({ message }) => message).join(ERROR_SEPARATOR));
|
|
100
|
+
this.stack = errors.map(({ stack }) => stack).join(ERROR_SEPARATOR);
|
|
101
|
+
this.code = types_1.RUNTIME_ERRORS.compositeArgumentsError;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.CompositeError = CompositeError;
|
|
105
|
+
class ReporterPluginError extends GeneralError {
|
|
106
|
+
constructor({ name, method, originalError }) {
|
|
107
|
+
const code = types_1.RUNTIME_ERRORS.uncaughtErrorInReporter;
|
|
108
|
+
super(code, name, method, originalError.stack);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.ReporterPluginError = ReporterPluginError;
|
|
112
|
+
class TimeoutError extends GeneralError {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(types_1.RUNTIME_ERRORS.timeLimitedPromiseTimeoutExpired);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.TimeoutError = TimeoutError;
|
|
118
|
+
class BrowserConnectionError extends GeneralError {
|
|
119
|
+
constructor(...args) {
|
|
120
|
+
super(types_1.RUNTIME_ERRORS.browserConnectionError, ...args);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.BrowserConnectionError = BrowserConnectionError;
|
|
124
124
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZXJyb3JzL3J1bnRpbWUvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEscURBQTRDO0FBQzVDLDREQUFvQztBQUNwQyxpRkFBdUQ7QUFDdkQsa0RBQXVEO0FBQ3ZELGtGQUF5RDtBQUN6RCw0RkFBa0U7QUFDbEUsb0NBQTBDO0FBRTFDLE1BQU0sZUFBZSxHQUFHLE1BQU0sQ0FBQztBQUUvQixNQUFNLDBCQUEwQjtJQUM1QixZQUFhLFNBQVM7UUFDbEIsSUFBSSxDQUFDLFNBQVMsR0FBRyxTQUFTLENBQUM7SUFDL0IsQ0FBQztDQUNKO0FBRUQsU0FBUztBQUNULE1BQWEsWUFBYSxTQUFRLEtBQUs7SUFDbkMsWU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