@badeball/cypress-configuration
Version:
[](https://github.com/badeball/cypress-configuration/actions/workflows/build.yml) [ • 3.06 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const strict_1 = __importDefault(require("assert/strict"));
const cypress_post10_configuration_parser_1 = require("./cypress-post10-configuration-parser");
function createSourceCode(options) {
const { type, withDefineCall, testingType, property, value: rawValue, } = options;
const value = (0, util_1.inspect)(rawValue);
if (type === "cjs") {
if (withDefineCall) {
return `module.exports = defineConfig({ ${testingType}: { ${property}: ${value} } });`;
}
else {
return `module.exports = { ${testingType}: { ${property}: ${value} } };`;
}
}
else {
if (withDefineCall) {
return `export default defineConfig({ ${testingType}: { ${property}: ${value} } });`;
}
else {
return `export default { ${testingType}: { ${property}: ${value} } };`;
}
}
}
function example(options) {
const { testingType, property, value } = options;
const expected = {
[testingType]: {
[property]: value,
},
};
for (const type of ["cjs", "esm"]) {
for (const withDefineCall of [false, true]) {
const description = `${type}, ${withDefineCall ? "with" : "without"} defineConfig`;
it(description, () => {
strict_1.default.deepStrictEqual((0, cypress_post10_configuration_parser_1.parsePost10Configuration)(createSourceCode({
type,
withDefineCall,
testingType,
property,
value,
})), expected);
});
}
}
}
describe("parsePost10Configuration()", () => {
for (const testingType of ["e2e", "component"]) {
describe(testingType, () => {
for (const property of ["specPattern", "excludeSpecPattern"]) {
describe(`${property} with string`, () => {
example({
testingType,
property,
value: "foo/bar",
});
});
describe(`${property} with string-array`, () => {
example({
testingType,
property,
value: ["foo/bar"],
});
});
}
describe("reporter", () => {
example({
testingType,
property: "reporter",
value: "foobar",
});
});
describe("env", () => {
example({
testingType,
property: "env",
value: { foo: "bar" },
});
});
});
}
});