106 lines
18 KiB
JavaScript
106 lines
18 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const lodash_1 = require("lodash");
|
|
const testing_unit_1 = __importDefault(require("./testing-unit"));
|
|
const unit_type_1 = __importDefault(require("./unit-type"));
|
|
const type_assertions_1 = require("../../errors/runtime/type-assertions");
|
|
const wrap_test_function_1 = __importDefault(require("../wrap-test-function"));
|
|
const assert_type_1 = __importDefault(require("../request-hooks/assert-type"));
|
|
const assert_type_2 = __importDefault(require("../../custom-client-scripts/assert-type"));
|
|
const types_1 = require("../../errors/types");
|
|
const runtime_1 = require("../../errors/runtime");
|
|
const option_names_1 = __importDefault(require("../../configuration/option-names"));
|
|
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
|
|
const test_timeout_1 = __importDefault(require("./test-timeout"));
|
|
const esm_runtime_holder_name_1 = __importDefault(require("../../services/compiler/esm-runtime-holder-name"));
|
|
class Test extends testing_unit_1.default {
|
|
constructor(testFile, isCompilerServiceMode = false, baseUrl, returnApiOrigin = true) {
|
|
// NOTE: 'fixture' directive can be missing
|
|
const fixture = testFile.currentFixture;
|
|
const pageUrl = (fixture === null || fixture === void 0 ? void 0 : fixture.pageUrl) || testcafe_hammerhead_1.SPECIAL_BLANK_PAGE;
|
|
super(testFile, unit_type_1.default.test, pageUrl, baseUrl);
|
|
this.fixture = null;
|
|
this.fn = null;
|
|
this.beforeFn = null;
|
|
this.afterFn = null;
|
|
this.globalBeforeFn = null;
|
|
this.globalAfterFn = null;
|
|
this.timeouts = null;
|
|
this._isCompilerService = isCompilerServiceMode;
|
|
this._initFixture(testFile);
|
|
// NOTE: This is internal data of 'esm' module
|
|
// @ts-ignore
|
|
this.esmRuntime = global[esm_runtime_holder_name_1.default] || null;
|
|
if (returnApiOrigin)
|
|
return this.apiOrigin;
|
|
}
|
|
static init({ testFile, baseUrl, isCompilerServiceMode }) {
|
|
return testing_unit_1.default.init(Test, testFile, isCompilerServiceMode, baseUrl);
|
|
}
|
|
_initFixture(testFile) {
|
|
this.fixture = testFile.currentFixture;
|
|
if (!this.fixture)
|
|
return;
|
|
this.pageUrl = this.fixture.pageUrl || testcafe_hammerhead_1.SPECIAL_BLANK_PAGE;
|
|
this.requestHooks = this.fixture.requestHooks.slice();
|
|
this.clientScripts = this.fixture.clientScripts.slice();
|
|
this.skipJsErrorsOptions = this.fixture.skipJsErrorsOptions;
|
|
}
|
|
_add(name, fn) {
|
|
if (this._isCompilerService && !this.fixture)
|
|
this._initFixture(this.testFile);
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.string, 'apiOrigin', 'The test name', name);
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'apiOrigin', 'The test body', fn);
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.nonNullObject, 'apiOrigin', `The fixture of '${name}' test`, this.fixture);
|
|
this.name = name;
|
|
this.fn = (0, wrap_test_function_1.default)(fn);
|
|
if (!this.testFile.collectedTests.includes(this))
|
|
this.testFile.collectedTests.push(this);
|
|
return this.apiOrigin;
|
|
}
|
|
_before$(fn) {
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'before', 'The test.before hook', fn);
|
|
this.beforeFn = (0, wrap_test_function_1.default)(fn);
|
|
return this.apiOrigin;
|
|
}
|
|
_after$(fn) {
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'after', 'The test.after hook', fn);
|
|
this.afterFn = (0, wrap_test_function_1.default)(fn);
|
|
return this.apiOrigin;
|
|
}
|
|
_requestHooks$(...hooks) {
|
|
if (this.apiMethodWasCalled.requestHooks)
|
|
throw new runtime_1.APIError(option_names_1.default.requestHooks, types_1.RUNTIME_ERRORS.multipleAPIMethodCallForbidden, option_names_1.default.requestHooks);
|
|
hooks = (0, lodash_1.flattenDeep)(hooks);
|
|
(0, assert_type_1.default)(hooks);
|
|
this.requestHooks = (0, lodash_1.union)(this.requestHooks, hooks);
|
|
this.apiMethodWasCalled.requestHooks = true;
|
|
return this.apiOrigin;
|
|
}
|
|
_clientScripts$(...scripts) {
|
|
if (this.apiMethodWasCalled.clientScripts)
|
|
throw new runtime_1.APIError(option_names_1.default.clientScripts, types_1.RUNTIME_ERRORS.multipleAPIMethodCallForbidden, option_names_1.default.clientScripts);
|
|
scripts = (0, lodash_1.flattenDeep)(scripts);
|
|
(0, assert_type_2.default)(scripts);
|
|
this.clientScripts = (0, lodash_1.union)(this.clientScripts, scripts);
|
|
this.apiMethodWasCalled.clientScripts = true;
|
|
return this.apiOrigin;
|
|
}
|
|
_timeouts$(timeouts) {
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.testTimeouts, 'timeouts', 'test.timeouts', timeouts);
|
|
Object.keys(test_timeout_1.default)
|
|
.filter(timeout => timeout in timeouts)
|
|
.forEach(timeout => {
|
|
(0, type_assertions_1.assertType)(type_assertions_1.is.nonNegativeNumber, 'timeouts', `test.timeouts.${timeout}`, timeouts[timeout]);
|
|
});
|
|
this.timeouts = timeouts;
|
|
return this.apiOrigin;
|
|
}
|
|
}
|
|
exports.default = Test;
|
|
testing_unit_1.default.makeAPIListForChildClass(Test);
|
|
module.exports = exports.default;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGkvc3RydWN0dXJlL3Rlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxtQ0FBdUQ7QUFDdkQsa0VBQXlDO0FBQ3pDLDREQUFtQztBQUNuQywwRUFBc0U7QUFDdEUsK0VBQXFEO0FBQ3JELCtFQUFpRTtBQUNqRSwwRkFBNkU7QUFDN0UsOENBQW9EO0FBQ3BELGtEQUFnRDtBQUNoRCxvRkFBNEQ7QUFLNUQsNkRBQXl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