@playwright-testing-library/test
Version:
playwright + dom-testing-library
30 lines • 1.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.reviver = exports.replacer = exports.TestingLibraryDeserializedFunction = void 0;
class TestingLibraryDeserializedFunction extends Function {
constructor(fn) {
super(`return (${fn}).apply(this, arguments)`);
this.original = fn;
}
}
exports.TestingLibraryDeserializedFunction = TestingLibraryDeserializedFunction;
const replacer = (_, value) => {
if (value instanceof RegExp)
return `__REGEXP ${value.toString()}`;
if (typeof value === 'function')
return `__FUNCTION ${value.toString()}`;
return value;
};
exports.replacer = replacer;
const reviver = (_, value) => {
if (value.toString().includes('__REGEXP ')) {
const match = /\/(.*)\/(.*)?/.exec(value.split('__REGEXP ')[1]);
return new RegExp(match[1], match[2] || '');
}
if (value.toString().includes('__FUNCTION ')) {
return new TestingLibraryDeserializedFunction(value.split('__FUNCTION ')[1]);
}
return value;
};
exports.reviver = reviver;
//# sourceMappingURL=helpers.js.map
;