system-testing 1.0.13 → 1.0.15

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.
@@ -0,0 +1,9 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ time: "01:00"
8
+ timezone: Europe/Berlin
9
+ open-pull-requests-limit: 99
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "system-testing",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "System testing with Selenium and browsers.",
5
5
  "keywords": [
6
6
  "system",
@@ -98,20 +98,32 @@ export default class SystemTestBrowserHelper {
98
98
  return this.originalConsoleLog(...args)
99
99
  }
100
100
 
101
- consoleLogMessage(arg) {
101
+ consoleLogMessage(arg, scannedObjects = []) {
102
102
  if (Array.isArray(arg)) {
103
+ if (scannedObjects.includes(arg)) {
104
+ return "[recursive]"
105
+ } else {
106
+ scannedObjects.push(arg)
107
+ }
108
+
103
109
  const result = []
104
110
 
105
111
  for (const value of arg) {
106
- result.push(this.consoleLogMessage(value))
112
+ result.push(this.consoleLogMessage(value, scannedObjects))
107
113
  }
108
114
 
109
115
  return result
110
116
  } else if (Object.prototype.toString.call(arg) === '[object Object]') {
117
+ if (scannedObjects.includes(arg)) {
118
+ return "[recursive]"
119
+ } else {
120
+ scannedObjects.push(arg)
121
+ }
122
+
111
123
  const result = {}
112
124
 
113
125
  for (const key in arg) {
114
- result[key] = this.consoleLogMessage(arg[key])
126
+ result[key] = this.consoleLogMessage(arg[key], scannedObjects)
115
127
  }
116
128
 
117
129
  return result
@@ -12,9 +12,9 @@ import {WebSocketServer} from "ws"
12
12
  class ElementNotFoundError extends Error { }
13
13
 
14
14
  export default class SystemTest {
15
- static current() {
15
+ static current(args) {
16
16
  if (!globalThis.systemTest) {
17
- globalThis.systemTest = new SystemTest()
17
+ globalThis.systemTest = new SystemTest(args)
18
18
  }
19
19
 
20
20
  return globalThis.systemTest
@@ -36,8 +36,16 @@ export default class SystemTest {
36
36
  }
37
37
  }
38
38
 
39
- constructor() {
39
+ constructor({host = "localhost", port = 8081, ...restArgs}) {
40
+ const restArgsKeys = Object.keys(restArgs)
41
+
42
+ if (restArgsKeys.length > 0) {
43
+ throw new Error(`Unknown arguments: ${restArgsKeys.join(", ")}`)
44
+ }
45
+
40
46
  this.communicator = new SystemTestCommunicator({onCommand: this.onCommandReceived})
47
+ this._host = host
48
+ this._port = port
41
49
  this._responses = {}
42
50
  this._sendCount = 0
43
51
  }
@@ -158,9 +166,9 @@ export default class SystemTest {
158
166
 
159
167
  async start() {
160
168
  if (process.env.SYSTEM_TEST_HOST == "expo-dev-server") {
161
- this.currentUrl = "http://localhost:8081"
169
+ this.currentUrl = `http://${this._host}:${this._port}`
162
170
  } else if (process.env.SYSTEM_TEST_HOST == "dist") {
163
- this.currentUrl = "http://localhost:1984"
171
+ this.currentUrl = `http://${this._host}:1984`
164
172
  this.systemTestHttpServer = new SystemTestHttpServer()
165
173
 
166
174
  await this.systemTestHttpServer.start()