@lvce-editor/test-with-playwright-worker 22.40.6 → 22.41.0
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/workerMain.js +122 -35
- package/package.json +3 -3
package/dist/workerMain.js
CHANGED
|
@@ -1566,6 +1566,41 @@ const compareSvgScreenshot = async ({
|
|
|
1566
1566
|
});
|
|
1567
1567
|
};
|
|
1568
1568
|
|
|
1569
|
+
const formatConsoleMessage = (type, message) => {
|
|
1570
|
+
const {
|
|
1571
|
+
columnNumber,
|
|
1572
|
+
lineNumber,
|
|
1573
|
+
url
|
|
1574
|
+
} = message.location();
|
|
1575
|
+
const location = url ? ` (${url}:${lineNumber}:${columnNumber})` : '';
|
|
1576
|
+
return `console ${type}: ${message.text()}${location}`;
|
|
1577
|
+
};
|
|
1578
|
+
const createPageMessages = page => {
|
|
1579
|
+
const messages = [];
|
|
1580
|
+
const onConsole = message => {
|
|
1581
|
+
const type = message.type();
|
|
1582
|
+
if (type === 'warning' || type === 'error') {
|
|
1583
|
+
messages.push(formatConsoleMessage(type, message));
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
const onPageError = error => {
|
|
1587
|
+
messages.push('uncaught page error: ' + (error.stack || error.message));
|
|
1588
|
+
};
|
|
1589
|
+
page.on('console', onConsole);
|
|
1590
|
+
page.on('pageerror', onPageError);
|
|
1591
|
+
return {
|
|
1592
|
+
dispose: () => {
|
|
1593
|
+
page.off('console', onConsole);
|
|
1594
|
+
page.off('pageerror', onPageError);
|
|
1595
|
+
},
|
|
1596
|
+
messages
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
const formatPageMessages = messages => {
|
|
1600
|
+
const formattedMessages = messages.map(message => ' ' + message).join('\n');
|
|
1601
|
+
return `Browser console messages:\n${formattedMessages}`;
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1569
1604
|
const Pass$1 = 1;
|
|
1570
1605
|
const Skip$1 = 2;
|
|
1571
1606
|
const Fail$1 = 3;
|
|
@@ -1594,6 +1629,7 @@ const withTimeout = async (promise, timeout) => {
|
|
|
1594
1629
|
};
|
|
1595
1630
|
const runElectronTest = async ({
|
|
1596
1631
|
electronApp,
|
|
1632
|
+
failOnConsoleMessages,
|
|
1597
1633
|
page,
|
|
1598
1634
|
svgScreenshotOptions,
|
|
1599
1635
|
test,
|
|
@@ -1601,53 +1637,67 @@ const runElectronTest = async ({
|
|
|
1601
1637
|
timeout
|
|
1602
1638
|
}) => {
|
|
1603
1639
|
const start = performance.now();
|
|
1640
|
+
const pageMessages = failOnConsoleMessages ? createPageMessages(page) : undefined;
|
|
1641
|
+
let result;
|
|
1604
1642
|
try {
|
|
1605
1643
|
const testModule = await importTestModule(testSrc, test);
|
|
1606
1644
|
if (testModule.skip) {
|
|
1607
1645
|
const end = performance.now();
|
|
1608
|
-
|
|
1646
|
+
result = {
|
|
1609
1647
|
end,
|
|
1610
1648
|
error: '',
|
|
1611
1649
|
name: test,
|
|
1612
1650
|
start,
|
|
1613
1651
|
status: Skip$1
|
|
1614
1652
|
};
|
|
1653
|
+
} else {
|
|
1654
|
+
const {
|
|
1655
|
+
expect
|
|
1656
|
+
} = await import('@playwright/test');
|
|
1657
|
+
await withTimeout(testModule.test({
|
|
1658
|
+
electronApp,
|
|
1659
|
+
expect,
|
|
1660
|
+
Locator: page.locator.bind(page),
|
|
1661
|
+
page
|
|
1662
|
+
}), timeout);
|
|
1663
|
+
if (svgScreenshotOptions) {
|
|
1664
|
+
await captureSvgScreenshot({
|
|
1665
|
+
options: svgScreenshotOptions,
|
|
1666
|
+
page,
|
|
1667
|
+
test
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
const end = performance.now();
|
|
1671
|
+
result = {
|
|
1672
|
+
end,
|
|
1673
|
+
error: '',
|
|
1674
|
+
name: test,
|
|
1675
|
+
start,
|
|
1676
|
+
status: Pass$1
|
|
1677
|
+
};
|
|
1615
1678
|
}
|
|
1616
|
-
const {
|
|
1617
|
-
expect
|
|
1618
|
-
} = await import('@playwright/test');
|
|
1619
|
-
await withTimeout(testModule.test({
|
|
1620
|
-
electronApp,
|
|
1621
|
-
expect,
|
|
1622
|
-
Locator: page.locator.bind(page),
|
|
1623
|
-
page
|
|
1624
|
-
}), timeout);
|
|
1625
|
-
if (svgScreenshotOptions) {
|
|
1626
|
-
await captureSvgScreenshot({
|
|
1627
|
-
options: svgScreenshotOptions,
|
|
1628
|
-
page,
|
|
1629
|
-
test
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
const end = performance.now();
|
|
1633
|
-
return {
|
|
1634
|
-
end,
|
|
1635
|
-
error: '',
|
|
1636
|
-
name: test,
|
|
1637
|
-
start,
|
|
1638
|
-
status: Pass$1
|
|
1639
|
-
};
|
|
1640
1679
|
} catch (error) {
|
|
1641
1680
|
const end = performance.now();
|
|
1642
1681
|
const message = error instanceof Error ? error.message : String(error);
|
|
1643
|
-
|
|
1682
|
+
result = {
|
|
1644
1683
|
end,
|
|
1645
1684
|
error: message,
|
|
1646
1685
|
name: test,
|
|
1647
1686
|
start,
|
|
1648
1687
|
status: Fail$1
|
|
1649
1688
|
};
|
|
1689
|
+
} finally {
|
|
1690
|
+
pageMessages?.dispose();
|
|
1691
|
+
}
|
|
1692
|
+
if (pageMessages && pageMessages.messages.length > 0) {
|
|
1693
|
+
const messages = formatPageMessages(pageMessages.messages);
|
|
1694
|
+
result = {
|
|
1695
|
+
...result,
|
|
1696
|
+
error: result.error ? `${result.error}\n${messages}` : messages,
|
|
1697
|
+
status: Fail$1
|
|
1698
|
+
};
|
|
1650
1699
|
}
|
|
1700
|
+
return result;
|
|
1651
1701
|
};
|
|
1652
1702
|
|
|
1653
1703
|
const getResultCounts$2 = status => {
|
|
@@ -1680,6 +1730,7 @@ const getResultCounts$2 = status => {
|
|
|
1680
1730
|
};
|
|
1681
1731
|
const runElectronTests = async ({
|
|
1682
1732
|
electronApp,
|
|
1733
|
+
failOnConsoleMessages,
|
|
1683
1734
|
filter,
|
|
1684
1735
|
onFinalResult,
|
|
1685
1736
|
onResult,
|
|
@@ -1697,6 +1748,7 @@ const runElectronTests = async ({
|
|
|
1697
1748
|
for (const test of filteredTests) {
|
|
1698
1749
|
const result = await runElectronTest({
|
|
1699
1750
|
electronApp,
|
|
1751
|
+
failOnConsoleMessages,
|
|
1700
1752
|
page,
|
|
1701
1753
|
test,
|
|
1702
1754
|
testSrc,
|
|
@@ -1775,6 +1827,7 @@ const navigateToTest = async (page, url, browser) => {
|
|
|
1775
1827
|
};
|
|
1776
1828
|
const runTest = async ({
|
|
1777
1829
|
browser,
|
|
1830
|
+
failOnConsoleMessages,
|
|
1778
1831
|
page,
|
|
1779
1832
|
port,
|
|
1780
1833
|
svgScreenshotOptions,
|
|
@@ -1785,6 +1838,8 @@ const runTest = async ({
|
|
|
1785
1838
|
traceRendererWorker
|
|
1786
1839
|
}) => {
|
|
1787
1840
|
const start = performance.now();
|
|
1841
|
+
const pageMessages = failOnConsoleMessages ? createPageMessages(page) : undefined;
|
|
1842
|
+
let result;
|
|
1788
1843
|
try {
|
|
1789
1844
|
const url = getUrlFromTestFile(test, port, traceFocus ?? false, traceRendererWorker ?? false);
|
|
1790
1845
|
await navigateToTest(page, url, browser);
|
|
@@ -1805,7 +1860,7 @@ const runTest = async ({
|
|
|
1805
1860
|
});
|
|
1806
1861
|
}
|
|
1807
1862
|
const end = performance.now();
|
|
1808
|
-
|
|
1863
|
+
result = {
|
|
1809
1864
|
// @ts-ignore
|
|
1810
1865
|
...testState,
|
|
1811
1866
|
end,
|
|
@@ -1816,14 +1871,25 @@ const runTest = async ({
|
|
|
1816
1871
|
} catch (error) {
|
|
1817
1872
|
const end = performance.now();
|
|
1818
1873
|
const message = error instanceof Error ? error.message : String(error);
|
|
1819
|
-
|
|
1874
|
+
result = {
|
|
1820
1875
|
end,
|
|
1821
1876
|
error: message,
|
|
1822
1877
|
name: test,
|
|
1823
1878
|
start,
|
|
1824
1879
|
status: Fail$1
|
|
1825
1880
|
};
|
|
1881
|
+
} finally {
|
|
1882
|
+
pageMessages?.dispose();
|
|
1883
|
+
}
|
|
1884
|
+
if (pageMessages && pageMessages.messages.length > 0) {
|
|
1885
|
+
const messages = formatPageMessages(pageMessages.messages);
|
|
1886
|
+
result = {
|
|
1887
|
+
...result,
|
|
1888
|
+
error: result.error ? `${result.error}\n${messages}` : messages,
|
|
1889
|
+
status: Fail$1
|
|
1890
|
+
};
|
|
1826
1891
|
}
|
|
1892
|
+
return result;
|
|
1827
1893
|
};
|
|
1828
1894
|
|
|
1829
1895
|
const getResultCounts$1 = status => {
|
|
@@ -1862,6 +1928,7 @@ const getResultCounts$1 = status => {
|
|
|
1862
1928
|
const runTests = async ({
|
|
1863
1929
|
browser = 'chromium',
|
|
1864
1930
|
createPage,
|
|
1931
|
+
failOnConsoleMessages,
|
|
1865
1932
|
filter,
|
|
1866
1933
|
headless,
|
|
1867
1934
|
onFinalResult,
|
|
@@ -1887,6 +1954,7 @@ const runTests = async ({
|
|
|
1887
1954
|
try {
|
|
1888
1955
|
const result = await runTest({
|
|
1889
1956
|
browser,
|
|
1957
|
+
failOnConsoleMessages,
|
|
1890
1958
|
page: currentPage,
|
|
1891
1959
|
port,
|
|
1892
1960
|
test,
|
|
@@ -2050,6 +2118,7 @@ const readTestResultsText = async (page, timeout) => {
|
|
|
2050
2118
|
};
|
|
2051
2119
|
const runTestsWithReusedPage = async ({
|
|
2052
2120
|
browser,
|
|
2121
|
+
failOnConsoleMessages,
|
|
2053
2122
|
filter,
|
|
2054
2123
|
onFinalResult,
|
|
2055
2124
|
onResult,
|
|
@@ -2060,6 +2129,7 @@ const runTestsWithReusedPage = async ({
|
|
|
2060
2129
|
traceFocus
|
|
2061
2130
|
}) => {
|
|
2062
2131
|
const start = performance.now();
|
|
2132
|
+
const pageMessages = failOnConsoleMessages ? createPageMessages(page) : undefined;
|
|
2063
2133
|
let results;
|
|
2064
2134
|
try {
|
|
2065
2135
|
const url = getAllTestsUrl(port, filter, traceFocus ?? false, rendererWorkerTraceDirectory !== undefined);
|
|
@@ -2072,12 +2142,25 @@ const runTestsWithReusedPage = async ({
|
|
|
2072
2142
|
} catch (error) {
|
|
2073
2143
|
results = [getFailedAllTestsResult(error, start)];
|
|
2074
2144
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2145
|
+
try {
|
|
2146
|
+
if (rendererWorkerTraceDirectory) {
|
|
2147
|
+
await exportTrace({
|
|
2148
|
+
directory: rendererWorkerTraceDirectory,
|
|
2149
|
+
page,
|
|
2150
|
+
test: '_all.html'
|
|
2151
|
+
});
|
|
2152
|
+
}
|
|
2153
|
+
} finally {
|
|
2154
|
+
pageMessages?.dispose();
|
|
2155
|
+
}
|
|
2156
|
+
if (pageMessages && pageMessages.messages.length > 0) {
|
|
2157
|
+
results = [...results, {
|
|
2158
|
+
end: performance.now(),
|
|
2159
|
+
error: formatPageMessages(pageMessages.messages),
|
|
2160
|
+
name: '_all.html (console messages)',
|
|
2161
|
+
start,
|
|
2162
|
+
status: Fail$1
|
|
2163
|
+
}];
|
|
2081
2164
|
}
|
|
2082
2165
|
let failed = 0;
|
|
2083
2166
|
let passed = 0;
|
|
@@ -2931,7 +3014,7 @@ const assertCoverageOptions = (coverageTarget, coverageInclude, coverageThreshol
|
|
|
2931
3014
|
* @param {boolean} coverage
|
|
2932
3015
|
* @param {boolean} traceRendererWorker
|
|
2933
3016
|
*/
|
|
2934
|
-
const runAllTests = async (extensionPath, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage, coverageInclude, coverageTarget, coverageThreshold, traceRendererWorker) => {
|
|
3017
|
+
const runAllTests = async (extensionPath, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage, coverageInclude, coverageTarget, coverageThreshold, traceRendererWorker, failOnConsoleMessages) => {
|
|
2935
3018
|
string(extensionPath);
|
|
2936
3019
|
string(testPath);
|
|
2937
3020
|
string(cwd);
|
|
@@ -2943,6 +3026,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2943
3026
|
boolean(coverage);
|
|
2944
3027
|
assertCoverageOptions(coverageTarget, coverageInclude, coverageThreshold);
|
|
2945
3028
|
boolean(traceRendererWorker);
|
|
3029
|
+
boolean(failOnConsoleMessages);
|
|
2946
3030
|
if (svgScreenshotOptions !== undefined) {
|
|
2947
3031
|
object(svgScreenshotOptions);
|
|
2948
3032
|
}
|
|
@@ -2988,6 +3072,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2988
3072
|
await runElectronTests({
|
|
2989
3073
|
...filterOption,
|
|
2990
3074
|
electronApp: electron.electronApp,
|
|
3075
|
+
failOnConsoleMessages,
|
|
2991
3076
|
onFinalResult,
|
|
2992
3077
|
onResult,
|
|
2993
3078
|
page: electron.page,
|
|
@@ -3042,6 +3127,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
3042
3127
|
await runTestsWithReusedPage({
|
|
3043
3128
|
browser,
|
|
3044
3129
|
...filterOption,
|
|
3130
|
+
failOnConsoleMessages,
|
|
3045
3131
|
onFinalResult,
|
|
3046
3132
|
onResult,
|
|
3047
3133
|
page,
|
|
@@ -3089,6 +3175,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
3089
3175
|
run: async () => {
|
|
3090
3176
|
await runTests({
|
|
3091
3177
|
browser,
|
|
3178
|
+
failOnConsoleMessages,
|
|
3092
3179
|
...(createPage && {
|
|
3093
3180
|
createPage
|
|
3094
3181
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/test-with-playwright-worker",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.41.0",
|
|
4
4
|
"description": "Worker package for test-with-playwright",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "dist/workerMain.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@playwright/test": "1.
|
|
15
|
+
"@playwright/test": "1.64.0",
|
|
16
16
|
"get-port": "^7.2.0",
|
|
17
|
-
"playwright-core": "^1.
|
|
17
|
+
"playwright-core": "^1.64.0"
|
|
18
18
|
},
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=24"
|