@brillout/test-e2e 0.6.19 → 0.6.21
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/Logs.d.ts +3 -1
- package/dist/Logs.js +10 -4
- package/dist/run.js +1 -1
- package/package.json +1 -1
package/dist/Logs.d.ts
CHANGED
|
@@ -33,11 +33,13 @@ declare function add({ logSource, logText, logInfo, loggedAfterExit, }: {
|
|
|
33
33
|
/**
|
|
34
34
|
* Expect a log to be printed.
|
|
35
35
|
*
|
|
36
|
+
* @param pattern String or RegExp to search for in logs.
|
|
37
|
+
*
|
|
36
38
|
* @param filter Only search in certain types of logs, e.g. only in browser- or server-side logs.
|
|
37
39
|
*
|
|
38
40
|
* @param allLogs Search in all logs, including the logs of previous tests as well as the logs of the setup/prepare scripts. Usually used in combination with the `filter` parameter.
|
|
39
41
|
*/
|
|
40
|
-
declare function expectLog(
|
|
42
|
+
declare function expectLog(pattern: string | RegExp, { filter: logFilter, allLogs }?: {
|
|
41
43
|
filter?: (logEntry: LogEntry) => boolean;
|
|
42
44
|
allLogs?: boolean;
|
|
43
45
|
}): void;
|
package/dist/Logs.js
CHANGED
|
@@ -115,28 +115,34 @@ async function terminateUponErrorLog(logSource) {
|
|
|
115
115
|
/**
|
|
116
116
|
* Expect a log to be printed.
|
|
117
117
|
*
|
|
118
|
+
* @param pattern String or RegExp to search for in logs.
|
|
119
|
+
*
|
|
118
120
|
* @param filter Only search in certain types of logs, e.g. only in browser- or server-side logs.
|
|
119
121
|
*
|
|
120
122
|
* @param allLogs Search in all logs, including the logs of previous tests as well as the logs of the setup/prepare scripts. Usually used in combination with the `filter` parameter.
|
|
121
123
|
*/
|
|
122
|
-
function expectLog(
|
|
124
|
+
function expectLog(pattern, { filter: logFilter, allLogs } = {}) {
|
|
123
125
|
const logList = allLogs ? logEntriesAll : logEntries;
|
|
126
|
+
const isRegex = pattern instanceof RegExp;
|
|
127
|
+
const patternStr = isRegex ? pattern.toString() : `"${pattern}"`;
|
|
124
128
|
const logsFound = logList.filter((logEntry) => {
|
|
125
|
-
|
|
129
|
+
const logText = removeAnsi(logEntry).logText;
|
|
130
|
+
const matches = isRegex ? pattern.test(logText) : logText.includes(pattern);
|
|
131
|
+
if (matches) {
|
|
126
132
|
logEntry.isNotFailure = true;
|
|
127
133
|
return true;
|
|
128
134
|
}
|
|
129
135
|
return false;
|
|
130
136
|
});
|
|
131
137
|
if (logsFound.length === 0) {
|
|
132
|
-
throw new Error(`The following log is expected but it wasn't logged:
|
|
138
|
+
throw new Error(`The following log is expected but it wasn't logged: ${patternStr}`);
|
|
133
139
|
}
|
|
134
140
|
if (!logFilter)
|
|
135
141
|
return;
|
|
136
142
|
const logsFoundAfterFilter = logsFound.filter((logEntry) => logFilter(removeAnsi(logEntry)));
|
|
137
143
|
if (logsFoundAfterFilter.length === 0) {
|
|
138
144
|
console.log(JSON.stringify(logsFound, null, 2));
|
|
139
|
-
throw new Error(`Logs above are matching
|
|
145
|
+
throw new Error(`Logs above are matching ${patternStr} but don't match the filter you provided.`);
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
function removeAnsi(logEntry) {
|
package/dist/run.js
CHANGED
|
@@ -114,7 +114,7 @@ async function startProcess({ serverIsReadyMessage, serverIsReadyDelay, addition
|
|
|
114
114
|
// npm package `serve`
|
|
115
115
|
log.includes('Accepting connections at') ||
|
|
116
116
|
// Vite
|
|
117
|
-
(log.includes('Local:') && log.includes('http://localhost:3000
|
|
117
|
+
(log.includes('Local:') && log.includes('http://localhost:3000'));
|
|
118
118
|
return serverIsReady;
|
|
119
119
|
};
|
|
120
120
|
}
|