@luigi-project/testing-utilities 2.8.1-dev.20240260024 → 2.8.1-dev.20240271713

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.
Files changed (2) hide show
  1. package/luigi-mock-util.js +33 -7
  2. package/package.json +3 -13
@@ -5,9 +5,20 @@ export class LuigiMockUtil {
5
5
  * @param mockContext an object representing the context to be mocked
6
6
  */
7
7
  this.mockContext = (mockContext) => {
8
- this.browser.executeScript((mockContext) => {
9
- globalThis.postMessage({ msg: 'luigi.get-context', context: mockContext }, '*');
10
- }, mockContext);
8
+ const postMessageToLuigi = (context) => {
9
+ globalThis.postMessage({ msg: 'luigi.get-context', context }, '*');
10
+ };
11
+ try {
12
+ if (this.browser.executeScript) {
13
+ this.browser.executeScript(postMessageToLuigi, mockContext);
14
+ }
15
+ else {
16
+ this.browser(postMessageToLuigi, mockContext);
17
+ }
18
+ }
19
+ catch (e) {
20
+ console.debug('Failed to mock context: ', e);
21
+ }
11
22
  };
12
23
  /**
13
24
  * This method serves as a mock for the luigi client pathExists() function.
@@ -26,7 +37,7 @@ export class LuigiMockUtil {
26
37
  *
27
38
  */
28
39
  this.mockPathExists = (path, exists) => {
29
- this.browser.executeScript((path, exists) => {
40
+ const setPathExistsMockData = (path, exists) => {
30
41
  globalThis.sessionStorage.clear();
31
42
  let pathExistsMockData = {
32
43
  pathExists: {
@@ -34,7 +45,19 @@ export class LuigiMockUtil {
34
45
  }
35
46
  };
36
47
  globalThis.sessionStorage.setItem('luigiMockData', JSON.stringify(pathExistsMockData));
37
- }, path, exists);
48
+ };
49
+ try {
50
+ if (this.browser.executeScript) {
51
+ this.browser.executeScript(setPathExistsMockData, path, exists);
52
+ }
53
+ else {
54
+ this.browser(setPathExistsMockData, path, exists);
55
+ }
56
+ }
57
+ catch (e) {
58
+ console.debug('Failed to mock path exists: ', e);
59
+ }
60
+ this.browser.executeScript ? this.browser.executeScript(setPathExistsMockData, path, exists) : this.browser(setPathExistsMockData, path, exists);
38
61
  };
39
62
  this.messages = [];
40
63
  this.browser = browser;
@@ -44,7 +67,10 @@ export class LuigiMockUtil {
44
67
  */
45
68
  async parseLuigiMockedMessages() {
46
69
  try {
47
- const textElements = await this.browser.executeScript(() => Array.from(document.getElementById('luigi-debug-vis-cnt').childNodes).map(item => item.textContent));
70
+ const getTextNodeValues = async () => Array.from(document.getElementById('luigi-debug-vis-cnt').childNodes).map((item) => item.textContent);
71
+ const textElements = this.browser.executeScript
72
+ ? await this.browser.executeScript(getTextNodeValues)
73
+ : await this.browser(getTextNodeValues);
48
74
  this.messages = textElements
49
75
  .map((item) => {
50
76
  try {
@@ -54,7 +80,7 @@ export class LuigiMockUtil {
54
80
  return undefined;
55
81
  }
56
82
  })
57
- .filter(item => item !== undefined);
83
+ .filter((item) => item !== undefined);
58
84
  }
59
85
  catch (e) {
60
86
  console.debug('Failed to parse luigi mocked messages: ', e);
package/package.json CHANGED
@@ -2,21 +2,11 @@
2
2
  "name": "@luigi-project/testing-utilities",
3
3
  "description": "Luigi testing utilities for standalone testing of microfrontends",
4
4
  "license": "Apache-2.0",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "tsc && npm run copy",
9
- "copy": "ncp package.json ./dist/package.json && ncp README.md ./dist/README.md",
10
- "bundle": "npm run build"
11
- },
12
- "types": "dist/index.d.ts",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
13
7
  "publishConfig": {
14
8
  "tag": "testing-utilities"
15
9
  },
16
- "devDependencies": {
17
- "ncp": "^2.0.0",
18
- "typescript": "4.8.2"
19
- },
20
10
  "repository": {
21
11
  "type": "git",
22
12
  "url": "ssh://github.com/SAP/luigi.git"
@@ -29,7 +19,7 @@
29
19
  "microfrontends",
30
20
  "testing"
31
21
  ],
32
- "version": "2.8.1-dev.20240260024",
22
+ "version": "2.8.1-dev.20240271713",
33
23
  "engines": {
34
24
  "node": ">=18"
35
25
  }