folio
Version:
A customizable test framework to build your own test frameworks. Foundation for the [Playwright test runner](https://github.com/microsoft/playwright-test).
58 lines • 2.26 kB
JavaScript
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.workerSpec = void 0;
const workerTest_1 = require("./workerTest");
const transform_1 = require("./transform");
const util_1 = require("./util");
const spec_1 = require("./spec");
let currentRunSuites;
function workerSpec(suite) {
const suites = [suite];
currentRunSuites = suites;
const it = (spec, folio, title, modifierFn, fn) => {
fn = fn || modifierFn;
const test = new workerTest_1.WorkerSpec(folio, title, fn, suites[0]);
const location = util_1.callLocation(suite.file);
test.file = location.file;
test.line = location.line;
test.column = location.column;
return test;
};
const describe = (spec, folio, title, modifierFn, fn) => {
fn = fn || modifierFn;
const child = new workerTest_1.WorkerSuite(folio, title, suites[0]);
const location = util_1.callLocation(suite.file);
child.file = location.file;
child.line = location.line;
child.column = location.column;
suites.unshift(child);
fn();
suites.shift();
};
spec_1.setImplementation({
it,
describe,
beforeEach: (folio, fn) => currentRunSuites[0]._addHook('beforeEach', fn),
afterEach: (folio, fn) => currentRunSuites[0]._addHook('afterEach', fn),
beforeAll: (folio, fn) => currentRunSuites[0]._addHook('beforeAll', fn),
afterAll: (folio, fn) => currentRunSuites[0]._addHook('afterAll', fn),
});
return transform_1.installTransform();
}
exports.workerSpec = workerSpec;
//# sourceMappingURL=workerSpec.js.map
;