webpipe-js 2.0.48 → 2.0.50
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/dist/index.cjs +55 -20
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +55 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1275,7 +1275,7 @@ var Parser = class {
|
|
|
1275
1275
|
const returnValue = this.parseBacktickString();
|
|
1276
1276
|
this.skipSpaces();
|
|
1277
1277
|
const end = this.pos;
|
|
1278
|
-
return { target, targetStart, returnValue, start, end };
|
|
1278
|
+
return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
|
|
1279
1279
|
}
|
|
1280
1280
|
parseMock() {
|
|
1281
1281
|
return this.parseMockHead("with");
|
|
@@ -1351,6 +1351,7 @@ var Parser = class {
|
|
|
1351
1351
|
name,
|
|
1352
1352
|
value,
|
|
1353
1353
|
format,
|
|
1354
|
+
lineNumber: this.getLineNumber(fullStart),
|
|
1354
1355
|
start: nameStart,
|
|
1355
1356
|
end: nameEnd,
|
|
1356
1357
|
fullStart,
|
|
@@ -1467,6 +1468,7 @@ var Parser = class {
|
|
|
1467
1468
|
headers,
|
|
1468
1469
|
cookies,
|
|
1469
1470
|
conditions,
|
|
1471
|
+
lineNumber: this.getLineNumber(start),
|
|
1470
1472
|
start,
|
|
1471
1473
|
end
|
|
1472
1474
|
};
|
|
@@ -1485,8 +1487,14 @@ var Parser = class {
|
|
|
1485
1487
|
const variables = [];
|
|
1486
1488
|
const mocks = [];
|
|
1487
1489
|
const tests = [];
|
|
1490
|
+
const comments = [];
|
|
1488
1491
|
while (true) {
|
|
1489
1492
|
this.skipSpaces();
|
|
1493
|
+
const comment = this.tryParse(() => this.parseStandaloneComment());
|
|
1494
|
+
if (comment) {
|
|
1495
|
+
comments.push(comment);
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1490
1498
|
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1491
1499
|
if (letBinding) {
|
|
1492
1500
|
variables.push(letBinding);
|
|
@@ -1511,7 +1519,7 @@ var Parser = class {
|
|
|
1511
1519
|
}
|
|
1512
1520
|
this.currentDescribeName = null;
|
|
1513
1521
|
const end = this.pos;
|
|
1514
|
-
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0, start, end };
|
|
1522
|
+
return { name, variables, mocks, tests, comments, inlineComment: inlineComment || void 0, start, end };
|
|
1515
1523
|
}
|
|
1516
1524
|
};
|
|
1517
1525
|
function parseProgram(text) {
|
|
@@ -1603,9 +1611,7 @@ function printVariable(variable) {
|
|
|
1603
1611
|
}
|
|
1604
1612
|
function printGraphQLSchema(schema) {
|
|
1605
1613
|
const firstLine = schema.inlineComment ? `graphqlSchema = \` ${printComment(schema.inlineComment)}` : "graphqlSchema = `";
|
|
1606
|
-
return `${firstLine}
|
|
1607
|
-
${schema.sdl}
|
|
1608
|
-
\``;
|
|
1614
|
+
return `${firstLine}${schema.sdl}\``;
|
|
1609
1615
|
}
|
|
1610
1616
|
function printQueryResolver(query) {
|
|
1611
1617
|
const lines = [];
|
|
@@ -1670,15 +1676,20 @@ function printCondition(condition, indent = " ") {
|
|
|
1670
1676
|
}
|
|
1671
1677
|
if (condition.field === "selector" && condition.selector && condition.domAssert) {
|
|
1672
1678
|
const selector = condition.selector;
|
|
1679
|
+
const formatSelectorValue = (val) => {
|
|
1680
|
+
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1681
|
+
if (/\{\{[^}]+\}\}/.test(val)) return `"${val}"`;
|
|
1682
|
+
return formatConditionValue(val);
|
|
1683
|
+
};
|
|
1673
1684
|
if (condition.domAssert.kind === "Exists") {
|
|
1674
1685
|
const operation = condition.comparison === "exists" ? "exists" : "does not exist";
|
|
1675
1686
|
return `${indent}${condType} selector \`${selector}\` ${operation}`;
|
|
1676
1687
|
} else if (condition.domAssert.kind === "Text") {
|
|
1677
|
-
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${
|
|
1688
|
+
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatSelectorValue(condition.value)}`;
|
|
1678
1689
|
} else if (condition.domAssert.kind === "Count") {
|
|
1679
1690
|
return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
|
|
1680
1691
|
} else if (condition.domAssert.kind === "Attribute") {
|
|
1681
|
-
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${
|
|
1692
|
+
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatSelectorValue(condition.value)}`;
|
|
1682
1693
|
}
|
|
1683
1694
|
}
|
|
1684
1695
|
const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
|
|
@@ -1740,22 +1751,46 @@ function printDescribe(describe) {
|
|
|
1740
1751
|
} else {
|
|
1741
1752
|
lines.push(describeLine);
|
|
1742
1753
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
});
|
|
1748
|
-
lines.push("");
|
|
1749
|
-
}
|
|
1754
|
+
const items = [];
|
|
1755
|
+
describe.variables.forEach((variable) => {
|
|
1756
|
+
items.push({ type: "variable", item: variable, lineNumber: variable.lineNumber || 0 });
|
|
1757
|
+
});
|
|
1750
1758
|
describe.mocks.forEach((mock) => {
|
|
1751
|
-
|
|
1759
|
+
items.push({ type: "mock", item: mock, lineNumber: mock.lineNumber || 0 });
|
|
1760
|
+
});
|
|
1761
|
+
describe.comments.forEach((comment) => {
|
|
1762
|
+
items.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
|
|
1752
1763
|
});
|
|
1753
|
-
if (describe.mocks.length > 0) {
|
|
1754
|
-
lines.push("");
|
|
1755
|
-
}
|
|
1756
1764
|
describe.tests.forEach((test) => {
|
|
1757
|
-
|
|
1758
|
-
|
|
1765
|
+
items.push({ type: "test", item: test, lineNumber: test.lineNumber || 0 });
|
|
1766
|
+
});
|
|
1767
|
+
items.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
1768
|
+
let lastType = null;
|
|
1769
|
+
items.forEach((entry) => {
|
|
1770
|
+
if (lastType === "variable" && entry.type !== "variable") {
|
|
1771
|
+
lines.push("");
|
|
1772
|
+
}
|
|
1773
|
+
switch (entry.type) {
|
|
1774
|
+
case "variable":
|
|
1775
|
+
const variable = entry.item;
|
|
1776
|
+
const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
|
|
1777
|
+
lines.push(` let ${variable.name} = ${formattedValue}`);
|
|
1778
|
+
break;
|
|
1779
|
+
case "mock":
|
|
1780
|
+
lines.push(printMock(entry.item));
|
|
1781
|
+
break;
|
|
1782
|
+
case "comment":
|
|
1783
|
+
lines.push(` ${printComment(entry.item)}`);
|
|
1784
|
+
break;
|
|
1785
|
+
case "test":
|
|
1786
|
+
if (lastType && lastType !== "test") {
|
|
1787
|
+
lines.push("");
|
|
1788
|
+
}
|
|
1789
|
+
lines.push(printTest(entry.item));
|
|
1790
|
+
lines.push("");
|
|
1791
|
+
break;
|
|
1792
|
+
}
|
|
1793
|
+
lastType = entry.type;
|
|
1759
1794
|
});
|
|
1760
1795
|
return lines.join("\n").replace(/\n\n$/, "\n");
|
|
1761
1796
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -125,6 +125,7 @@ interface LetVariable {
|
|
|
125
125
|
name: string;
|
|
126
126
|
value: string;
|
|
127
127
|
format: LetValueFormat;
|
|
128
|
+
lineNumber?: number;
|
|
128
129
|
start: number;
|
|
129
130
|
end: number;
|
|
130
131
|
fullStart: number;
|
|
@@ -215,6 +216,7 @@ interface Describe {
|
|
|
215
216
|
variables: LetVariable[];
|
|
216
217
|
mocks: Mock[];
|
|
217
218
|
tests: It[];
|
|
219
|
+
comments: Comment[];
|
|
218
220
|
lineNumber?: number;
|
|
219
221
|
inlineComment?: Comment;
|
|
220
222
|
start: number;
|
|
@@ -224,6 +226,7 @@ interface Mock {
|
|
|
224
226
|
target: string;
|
|
225
227
|
targetStart: number;
|
|
226
228
|
returnValue: string;
|
|
229
|
+
lineNumber?: number;
|
|
227
230
|
start: number;
|
|
228
231
|
end: number;
|
|
229
232
|
}
|
|
@@ -237,6 +240,7 @@ interface It {
|
|
|
237
240
|
headers?: string;
|
|
238
241
|
cookies?: string;
|
|
239
242
|
conditions: Condition[];
|
|
243
|
+
lineNumber?: number;
|
|
240
244
|
start: number;
|
|
241
245
|
end: number;
|
|
242
246
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ interface LetVariable {
|
|
|
125
125
|
name: string;
|
|
126
126
|
value: string;
|
|
127
127
|
format: LetValueFormat;
|
|
128
|
+
lineNumber?: number;
|
|
128
129
|
start: number;
|
|
129
130
|
end: number;
|
|
130
131
|
fullStart: number;
|
|
@@ -215,6 +216,7 @@ interface Describe {
|
|
|
215
216
|
variables: LetVariable[];
|
|
216
217
|
mocks: Mock[];
|
|
217
218
|
tests: It[];
|
|
219
|
+
comments: Comment[];
|
|
218
220
|
lineNumber?: number;
|
|
219
221
|
inlineComment?: Comment;
|
|
220
222
|
start: number;
|
|
@@ -224,6 +226,7 @@ interface Mock {
|
|
|
224
226
|
target: string;
|
|
225
227
|
targetStart: number;
|
|
226
228
|
returnValue: string;
|
|
229
|
+
lineNumber?: number;
|
|
227
230
|
start: number;
|
|
228
231
|
end: number;
|
|
229
232
|
}
|
|
@@ -237,6 +240,7 @@ interface It {
|
|
|
237
240
|
headers?: string;
|
|
238
241
|
cookies?: string;
|
|
239
242
|
conditions: Condition[];
|
|
243
|
+
lineNumber?: number;
|
|
240
244
|
start: number;
|
|
241
245
|
end: number;
|
|
242
246
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1222,7 +1222,7 @@ var Parser = class {
|
|
|
1222
1222
|
const returnValue = this.parseBacktickString();
|
|
1223
1223
|
this.skipSpaces();
|
|
1224
1224
|
const end = this.pos;
|
|
1225
|
-
return { target, targetStart, returnValue, start, end };
|
|
1225
|
+
return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
|
|
1226
1226
|
}
|
|
1227
1227
|
parseMock() {
|
|
1228
1228
|
return this.parseMockHead("with");
|
|
@@ -1298,6 +1298,7 @@ var Parser = class {
|
|
|
1298
1298
|
name,
|
|
1299
1299
|
value,
|
|
1300
1300
|
format,
|
|
1301
|
+
lineNumber: this.getLineNumber(fullStart),
|
|
1301
1302
|
start: nameStart,
|
|
1302
1303
|
end: nameEnd,
|
|
1303
1304
|
fullStart,
|
|
@@ -1414,6 +1415,7 @@ var Parser = class {
|
|
|
1414
1415
|
headers,
|
|
1415
1416
|
cookies,
|
|
1416
1417
|
conditions,
|
|
1418
|
+
lineNumber: this.getLineNumber(start),
|
|
1417
1419
|
start,
|
|
1418
1420
|
end
|
|
1419
1421
|
};
|
|
@@ -1432,8 +1434,14 @@ var Parser = class {
|
|
|
1432
1434
|
const variables = [];
|
|
1433
1435
|
const mocks = [];
|
|
1434
1436
|
const tests = [];
|
|
1437
|
+
const comments = [];
|
|
1435
1438
|
while (true) {
|
|
1436
1439
|
this.skipSpaces();
|
|
1440
|
+
const comment = this.tryParse(() => this.parseStandaloneComment());
|
|
1441
|
+
if (comment) {
|
|
1442
|
+
comments.push(comment);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1437
1445
|
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1438
1446
|
if (letBinding) {
|
|
1439
1447
|
variables.push(letBinding);
|
|
@@ -1458,7 +1466,7 @@ var Parser = class {
|
|
|
1458
1466
|
}
|
|
1459
1467
|
this.currentDescribeName = null;
|
|
1460
1468
|
const end = this.pos;
|
|
1461
|
-
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0, start, end };
|
|
1469
|
+
return { name, variables, mocks, tests, comments, inlineComment: inlineComment || void 0, start, end };
|
|
1462
1470
|
}
|
|
1463
1471
|
};
|
|
1464
1472
|
function parseProgram(text) {
|
|
@@ -1550,9 +1558,7 @@ function printVariable(variable) {
|
|
|
1550
1558
|
}
|
|
1551
1559
|
function printGraphQLSchema(schema) {
|
|
1552
1560
|
const firstLine = schema.inlineComment ? `graphqlSchema = \` ${printComment(schema.inlineComment)}` : "graphqlSchema = `";
|
|
1553
|
-
return `${firstLine}
|
|
1554
|
-
${schema.sdl}
|
|
1555
|
-
\``;
|
|
1561
|
+
return `${firstLine}${schema.sdl}\``;
|
|
1556
1562
|
}
|
|
1557
1563
|
function printQueryResolver(query) {
|
|
1558
1564
|
const lines = [];
|
|
@@ -1617,15 +1623,20 @@ function printCondition(condition, indent = " ") {
|
|
|
1617
1623
|
}
|
|
1618
1624
|
if (condition.field === "selector" && condition.selector && condition.domAssert) {
|
|
1619
1625
|
const selector = condition.selector;
|
|
1626
|
+
const formatSelectorValue = (val) => {
|
|
1627
|
+
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1628
|
+
if (/\{\{[^}]+\}\}/.test(val)) return `"${val}"`;
|
|
1629
|
+
return formatConditionValue(val);
|
|
1630
|
+
};
|
|
1620
1631
|
if (condition.domAssert.kind === "Exists") {
|
|
1621
1632
|
const operation = condition.comparison === "exists" ? "exists" : "does not exist";
|
|
1622
1633
|
return `${indent}${condType} selector \`${selector}\` ${operation}`;
|
|
1623
1634
|
} else if (condition.domAssert.kind === "Text") {
|
|
1624
|
-
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${
|
|
1635
|
+
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatSelectorValue(condition.value)}`;
|
|
1625
1636
|
} else if (condition.domAssert.kind === "Count") {
|
|
1626
1637
|
return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
|
|
1627
1638
|
} else if (condition.domAssert.kind === "Attribute") {
|
|
1628
|
-
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${
|
|
1639
|
+
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatSelectorValue(condition.value)}`;
|
|
1629
1640
|
}
|
|
1630
1641
|
}
|
|
1631
1642
|
const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
|
|
@@ -1687,22 +1698,46 @@ function printDescribe(describe) {
|
|
|
1687
1698
|
} else {
|
|
1688
1699
|
lines.push(describeLine);
|
|
1689
1700
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
});
|
|
1695
|
-
lines.push("");
|
|
1696
|
-
}
|
|
1701
|
+
const items = [];
|
|
1702
|
+
describe.variables.forEach((variable) => {
|
|
1703
|
+
items.push({ type: "variable", item: variable, lineNumber: variable.lineNumber || 0 });
|
|
1704
|
+
});
|
|
1697
1705
|
describe.mocks.forEach((mock) => {
|
|
1698
|
-
|
|
1706
|
+
items.push({ type: "mock", item: mock, lineNumber: mock.lineNumber || 0 });
|
|
1707
|
+
});
|
|
1708
|
+
describe.comments.forEach((comment) => {
|
|
1709
|
+
items.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
|
|
1699
1710
|
});
|
|
1700
|
-
if (describe.mocks.length > 0) {
|
|
1701
|
-
lines.push("");
|
|
1702
|
-
}
|
|
1703
1711
|
describe.tests.forEach((test) => {
|
|
1704
|
-
|
|
1705
|
-
|
|
1712
|
+
items.push({ type: "test", item: test, lineNumber: test.lineNumber || 0 });
|
|
1713
|
+
});
|
|
1714
|
+
items.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
1715
|
+
let lastType = null;
|
|
1716
|
+
items.forEach((entry) => {
|
|
1717
|
+
if (lastType === "variable" && entry.type !== "variable") {
|
|
1718
|
+
lines.push("");
|
|
1719
|
+
}
|
|
1720
|
+
switch (entry.type) {
|
|
1721
|
+
case "variable":
|
|
1722
|
+
const variable = entry.item;
|
|
1723
|
+
const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
|
|
1724
|
+
lines.push(` let ${variable.name} = ${formattedValue}`);
|
|
1725
|
+
break;
|
|
1726
|
+
case "mock":
|
|
1727
|
+
lines.push(printMock(entry.item));
|
|
1728
|
+
break;
|
|
1729
|
+
case "comment":
|
|
1730
|
+
lines.push(` ${printComment(entry.item)}`);
|
|
1731
|
+
break;
|
|
1732
|
+
case "test":
|
|
1733
|
+
if (lastType && lastType !== "test") {
|
|
1734
|
+
lines.push("");
|
|
1735
|
+
}
|
|
1736
|
+
lines.push(printTest(entry.item));
|
|
1737
|
+
lines.push("");
|
|
1738
|
+
break;
|
|
1739
|
+
}
|
|
1740
|
+
lastType = entry.type;
|
|
1706
1741
|
});
|
|
1707
1742
|
return lines.join("\n").replace(/\n\n$/, "\n");
|
|
1708
1743
|
}
|