sefiutils 1.0.49 → 1.0.51

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/README.md CHANGED
@@ -1,9 +1,20 @@
1
- [![npm](https://img.shields.io/npm/v/restmatcher)](https://www.npmjs.com/package/sefiutils)
1
+ [![npm](https://img.shields.io/npm/v/sefiutils)](https://www.npmjs.com/package/sefiutils)
2
2
  [![pipeline status](https://gitlab.bht-berlin.de/nodepackages/sefiutils/badges/main/pipeline.svg)](https://gitlab.bht-berlin.de/nodepackages/sefiutils/pipelines/latest)
3
+ [![coverage](https://gitlab.bht-berlin.de/nodepackages/sefiutils/badges/main/coverage.svg)](https://gitlab.bht-berlin.de/nodepackages/sefiutils/pipelines/latest)
3
4
 
4
- # ![logo](https://gitlab.bht-berlin.de/nodepackages/sefiutils/-/raw/main/logo.png) sefiutils
5
+ ![logo](https://gitlab.bht-berlin.de/nodepackages/sefiutils/-/raw/main/logo.png) sefiutils
6
+ ======================
5
7
  **Utilities (and Jest tests) for Selenium Webdriver Tests and some React tools as well**
6
8
 
9
+ <details>
10
+ <summary>Table of Contents</summary>
11
+
12
+ [[_TOC_]]
13
+
14
+ </details>
15
+
16
+ # Overview
17
+
7
18
  This package provides some utility functions for Selenium Webdriver.
8
19
  It also adds some utilities for React Fiber in order to make it easier to test React components --
9
20
  however it has no dependency to React itself.
@@ -11,7 +22,7 @@ Additionally setup and teardown functions for Jest are provided.
11
22
 
12
23
  If you want to test your web app, you probably want to use other frameworks. This package is intended for use in teaching, in particular for grading student's projects. Thus it provides some utilities which are usually not available in other frameworks (as they are usually not required at all).
13
24
 
14
- ## Install
25
+ # Install
15
26
 
16
27
  Install with npm:
17
28
 
@@ -19,7 +30,7 @@ Install with npm:
19
30
  npm install --save-dev sefiutils
20
31
  ```
21
32
 
22
- ## Usage
33
+ # Usage
23
34
 
24
35
  In your jest.config.js file add the following lines:
25
36
 
@@ -76,6 +87,7 @@ afterAll(async () => {
76
87
  });
77
88
  ```
78
89
 
90
+ # Utility Functions
79
91
 
80
92
  ## Utils for accessing information from the DOM via Selenium Webdriver injected JavaScript
81
93
 
@@ -97,8 +109,6 @@ Most utility functions are provided via module 'seUtils', e.g.
97
109
  Most of these functions are scripts executed in the browser via Selenium Webdriver's `executeScript` function.
98
110
 
99
111
 
100
-
101
-
102
112
  ## Utils for React Fiber
103
113
 
104
114
  If you want to test the React components hierarchy, you can use the following functions:
@@ -144,23 +154,26 @@ In order to see what's going on, set environment variable `SEFI_VERBOSE` to true
144
154
 
145
155
  If you have problems starting the driver or something like that, set the environment variable `SEFI_DEBUG` to true. This will output information about local start up process.
146
156
 
147
- ## Docker Hints
157
+ # Docker Hints
148
158
 
149
- If you want to run your tests in a docker container on macos with M1 or M2 processor, you can use the following Dockerfile:
159
+ If you want to run your JavaScript tests in a docker container, you can use the following Dockerfile `seleniumnode20`:
150
160
 
151
161
  ```
152
- FROM seleniarm/standalone-firefox:latest
162
+ # build with: docker build -t seleniumnode20 .
163
+ # User: seluser, Home: /home/seluser, Shell: /bin/bash
164
+ FROM selenium/standalone-firefox:latest
153
165
 
154
- # install Node 18 and NPM
166
+ # install Node 20 and NPM
155
167
  RUN sudo apt update
156
- RUN sudo apt install nodejs npm -y
168
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
169
+ RUN sudo apt install -y nodejs
157
170
 
158
171
  CMD ["/bin/bash"]
159
172
  ```
160
173
 
161
174
  The default user ist "seluser", i.e. home folder is found in "/home/seluser".
162
175
 
163
- ## Troubleshooting and configuration
176
+ # Configuration
164
177
 
165
178
  Several environment variables can be used to configure SEFIUTILS.
166
179
 
@@ -170,10 +183,13 @@ Several environment variables can be used to configure SEFIUTILS.
170
183
  - SEFI_SELENIUM_REMOTE_URL, the URL, only the port is really configurable, default http://localhost:4444/wd/hub
171
184
  - SEFI_SELENIUM_SERVER_START_TIMEOUT, timeout when starting the remote selenium server, default 5000
172
185
  - SEFI_SELENIUM_SERVER_DOWNLOAD_URL, URL (prefix) from where the selenium server jar will be downloaded, default https://github.com/SeleniumHQ/selenium/releases/download
186
+ - SEFI_SELENIUM_CACHE_FOLDER: The folder to which the selenium server jar is downloaded (inside a folder ./cache and the selenium version). If not specified, the homefolder of the current user is used. However, in some cases (Docker, Gitlab) this is not possible.
173
187
 
174
188
 
175
189
  The environment is also passed to Selenium, so specific Selenium configurations can be set as well.
176
190
 
191
+ # Troubleshooting
192
+
177
193
  If the selenium server cannot be started, you might check whether any server is listing at the port via
178
194
  ```
179
195
  lsof -i :4444 -t
@@ -182,6 +198,6 @@ lsof -i :4444 -t
182
198
  (and you might kill it via `kill -15 $(lsof -i :4444 -t)`)
183
199
 
184
200
 
185
- ## License
201
+ # License
186
202
 
187
203
  This program and the accompanying materials are made available under the terms of the Eclipse Public License v. 2.0 which is available at https://www.eclipse.org/legal/epl-2.0.
@@ -95,12 +95,12 @@ function getSeleniumServerJar() {
95
95
  throw new Error(`Invalid version number: ${seleniumServerVersion}`);
96
96
  }
97
97
  const jarName = `selenium-server-${versionParts[0]}.${versionParts[1]}.${versionParts[2]}.jar`;
98
- const homeDir = (0, os_1.homedir)();
98
+ const homeDir = process.env.SEFI_SELENIUM_CACHE_FOLDER || (0, os_1.homedir)();
99
99
  const cachedPath = path_1.default.resolve(path_1.default.join(homeDir, ".cache", "selenium-server", jarName));
100
100
  (0, log_1.verbose)(`Selenium server jar: ${cachedPath}`);
101
101
  if (!fs_1.default.existsSync(cachedPath)) {
102
102
  if (!fs_1.default.existsSync(path_1.default.dirname(cachedPath))) {
103
- fs_1.default.mkdirSync(path_1.default.dirname(cachedPath));
103
+ fs_1.default.mkdirSync(path_1.default.dirname(cachedPath), { recursive: true });
104
104
  }
105
105
  const downloadURL = process.env.SEFI_SELENIUM_SERVER_DOWNLOAD_URL || "https://github.com/SeleniumHQ/selenium/releases/download";
106
106
  const url = `${downloadURL}/selenium-${versionParts[0]}.${versionParts[1]}.0/${jarName}`;
@@ -1 +1 @@
1
- {"version":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AAC;QAEzD,MAAM,OAAO,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAE7C,IAAI,UAAU,CAAC,MAAM,EAAE;YACnB,MAAM,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAA,aAAO,EAAC,sCAAsC,CAAC,CAAC;SACnD;QAED,MAAM,EAAE,IAAI,EAAC,GAAG,IAAA,iCAAuB,GAAE,CAAC;QAE1C,IAAA,WAAK,EAAC,GAAE,EAAE,CAAA,iCAAiC,IAAI,kEAAkE,CAAC,CAAC;QACnH,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE;YACzC,IAAI,EAAE,IAAI;YACV,GAAG,kCACI,OAAO,CAAC,GAAG,KACd,sBAAsB,EAAE,GAAG,EAC3B,+BAA+B,EAAE,MAAM,GAE1C;SACJ,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kCAAkC,IAAI,MAAM,CAAC,CAAC;QACnF,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QACtB,oDAAoD;QACpD,IAAA,WAAK,EAAC,GAAE,EAAE,CAAA,+BAA+B,aAAa,EAAE,CAAC,CAAC;IAC9D,CAAC;CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sefiutils",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "Utilities (and Jest tests) for Selenium Webdriver Tests and some React tools as well",
5
5
  "author": "Jens von Pilgrim <jens.vonpilgrim@bht-berlin.de>",
6
6
  "license": "EPL-2.0",
@@ -21,19 +21,19 @@
21
21
  "prepack": "npm run build"
22
22
  },
23
23
  "dependencies": {
24
- "dotenv": "^16.3.1",
25
- "geckodriver": "^4.3.0",
26
- "selenium-webdriver": "^4.10.0"
24
+ "dotenv": "^16.4.5",
25
+ "geckodriver": "^4.4.2",
26
+ "selenium-webdriver": "^4.23.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/jest": "^29.5.3",
30
- "@types/node": "^20.4.1",
31
- "@types/selenium-webdriver": "^4.1.15",
29
+ "@types/jest": "^29.5.12",
30
+ "@types/node": "^22.3.0",
31
+ "@types/selenium-webdriver": "^4.1.25",
32
32
  "copyfiles": "^2.4.1",
33
- "jest": "^29.6.1",
33
+ "jest": "^29.7.0",
34
34
  "jest-junit": "^16.0.0",
35
- "rimraf": "^5.0.1",
36
- "ts-jest": "^29.1.1",
37
- "typescript": "^5.1.6"
35
+ "rimraf": "^6.0.1",
36
+ "ts-jest": "^29.2.4",
37
+ "typescript": "^5.5.4"
38
38
  }
39
39
  }
@@ -60,12 +60,12 @@ export async function getSeleniumServerJar() {
60
60
  throw new Error(`Invalid version number: ${seleniumServerVersion}`);
61
61
  }
62
62
  const jarName = `selenium-server-${versionParts[0]}.${versionParts[1]}.${versionParts[2]}.jar`;
63
- const homeDir = homedir();
63
+ const homeDir = process.env.SEFI_SELENIUM_CACHE_FOLDER || homedir();
64
64
  const cachedPath = path.resolve(path.join(homeDir, ".cache", "selenium-server", jarName));
65
65
  verbose(`Selenium server jar: ${cachedPath}`);
66
66
  if (! fs.existsSync(cachedPath)) {
67
67
  if (! fs.existsSync(path.dirname(cachedPath))) {
68
- fs.mkdirSync(path.dirname(cachedPath));
68
+ fs.mkdirSync(path.dirname(cachedPath), {recursive: true});
69
69
  }
70
70
  const downloadURL = process.env.SEFI_SELENIUM_SERVER_DOWNLOAD_URL || "https://github.com/SeleniumHQ/selenium/releases/download";
71
71
  const url = `${downloadURL}/selenium-${versionParts[0]}.${versionParts[1]}.0/${jarName}`;