@lynx-js/testing-environment 0.1.7 → 0.1.8
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/CHANGELOG.md +8 -0
- package/dist/env/vitest/index.cjs +2 -0
- package/dist/env/vitest/index.d.ts +1 -1
- package/dist/env/vitest/index.js +2 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +2 -6
- package/dist/index.js +2 -1
- package/dist/lynx/ElementPAPI.d.ts +19 -2
- package/dist/lynx/GlobalThis.d.ts +8 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lynx-js/testing-environment
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix the "ReferenceError: Node is not defined" error. ([#1850](https://github.com/lynx-family/lynx-stack/pull/1850))
|
|
8
|
+
|
|
9
|
+
This error would happen when upgrading to `@testing-library/jest-dom` [v6.9.0](https://github.com/testing-library/jest-dom/releases/tag/v6.9.0).
|
|
10
|
+
|
|
3
11
|
## 0.1.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -36,10 +36,12 @@ const env = {
|
|
|
36
36
|
await environments_namespaceObject.builtinEnvironments.jsdom.setup(fakeGlobal, {});
|
|
37
37
|
const lynxTestingEnv = new testing_environment_namespaceObject.LynxTestingEnv(fakeGlobal.jsdom);
|
|
38
38
|
global.lynxTestingEnv = lynxTestingEnv;
|
|
39
|
+
global.Node = lynxTestingEnv.jsdom.window.Node;
|
|
39
40
|
return {
|
|
40
41
|
teardown (global) {
|
|
41
42
|
delete global.lynxTestingEnv;
|
|
42
43
|
delete global.jsdom;
|
|
44
|
+
delete global.Node;
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
}
|
package/dist/env/vitest/index.js
CHANGED
|
@@ -8,10 +8,12 @@ const env = {
|
|
|
8
8
|
await builtinEnvironments.jsdom.setup(fakeGlobal, {});
|
|
9
9
|
const lynxTestingEnv = new LynxTestingEnv(fakeGlobal.jsdom);
|
|
10
10
|
global.lynxTestingEnv = lynxTestingEnv;
|
|
11
|
+
global.Node = lynxTestingEnv.jsdom.window.Node;
|
|
11
12
|
return {
|
|
12
13
|
teardown (global) {
|
|
13
14
|
delete global.lynxTestingEnv;
|
|
14
15
|
delete global.jsdom;
|
|
16
|
+
delete global.Node;
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
19
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -72,11 +72,12 @@ function __injectElementApi(target) {
|
|
|
72
72
|
function createPolyfills() {
|
|
73
73
|
const app = {
|
|
74
74
|
callLepusMethod: (...rLynxChange)=>{
|
|
75
|
+
var _rLynxChange_;
|
|
75
76
|
const isBackground = !__MAIN_THREAD__;
|
|
76
77
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
77
78
|
globalThis[rLynxChange[0]](rLynxChange[1]);
|
|
78
79
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
79
|
-
rLynxChange[2]();
|
|
80
|
+
null == (_rLynxChange_ = rLynxChange[2]) || _rLynxChange_.call(rLynxChange);
|
|
80
81
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
81
82
|
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
82
83
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
|
-
*
|
|
4
|
-
* A pure-JavaScript implementation of the {@link https://lynxjs.org/guide/spec.html | Lynx Spec},
|
|
5
|
-
* notably the {@link https://lynxjs.org/api/engine/element-api | Element PAPI} and {@link https://lynxjs.org/guide/spec#dual-threaded-model | Dual-threaded Model} for use with Node.js.
|
|
6
|
-
*/
|
|
7
1
|
import { JSDOM } from 'jsdom';
|
|
8
2
|
import { LynxGlobalThis } from './lynx/GlobalThis.js';
|
|
9
3
|
import { initElementTree } from './lynx/ElementPAPI.js';
|
|
@@ -109,6 +103,8 @@ export declare class LynxTestingEnv {
|
|
|
109
103
|
injectGlobals(): void;
|
|
110
104
|
switchToBackgroundThread(): void;
|
|
111
105
|
switchToMainThread(): void;
|
|
106
|
+
// we do not use it because we have to keep background thread
|
|
107
|
+
// otherwise we will get error on __MAIN_THREAD__/__BACKGROUND__/lynx not defined etc.
|
|
112
108
|
clearGlobal(): void;
|
|
113
109
|
reset(): void;
|
|
114
110
|
}
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,12 @@ function __injectElementApi(target) {
|
|
|
33
33
|
function createPolyfills() {
|
|
34
34
|
const app = {
|
|
35
35
|
callLepusMethod: (...rLynxChange)=>{
|
|
36
|
+
var _rLynxChange_;
|
|
36
37
|
const isBackground = !__MAIN_THREAD__;
|
|
37
38
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
38
39
|
globalThis[rLynxChange[0]](rLynxChange[1]);
|
|
39
40
|
globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
40
|
-
rLynxChange[2]();
|
|
41
|
+
null == (_rLynxChange_ = rLynxChange[2]) || _rLynxChange_.call(rLynxChange);
|
|
41
42
|
globalThis.lynxTestingEnv.switchToMainThread();
|
|
42
43
|
if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
|
|
43
44
|
},
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
1
6
|
/**
|
|
2
7
|
* Any Lynx Element, such as `view`, `text`, `image`, etc.
|
|
3
8
|
*
|
|
@@ -6,6 +11,18 @@
|
|
|
6
11
|
* @public
|
|
7
12
|
*/
|
|
8
13
|
export interface LynxElement extends HTMLElement {
|
|
14
|
+
/**
|
|
15
|
+
* The unique id of the element.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
$$uiSign: number;
|
|
20
|
+
/**
|
|
21
|
+
* The unique id of the parent of the element.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
parentComponentUniqueId: number;
|
|
9
26
|
/**
|
|
10
27
|
* The map of events bound to the element.
|
|
11
28
|
*/
|
|
@@ -61,7 +78,7 @@ export declare const initElementTree: () => {
|
|
|
61
78
|
__CreateWrapperElement(parentComponentUniqueId: number): LynxElement;
|
|
62
79
|
__AddInlineStyle(e: HTMLElement, key: number, value: string): void;
|
|
63
80
|
__AppendElement(parent: LynxElement, child: LynxElement): void;
|
|
64
|
-
__SetCSSId(e: LynxElement | LynxElement
|
|
81
|
+
__SetCSSId(e: LynxElement[] | LynxElement, id: string, entryName?: string | undefined): void;
|
|
65
82
|
__SetAttribute(e: LynxElement, key: string, value: any): void;
|
|
66
83
|
__AddEvent(e: LynxElement, eventType: string, eventName: string, eventHandler: string | Record<string, any>): void;
|
|
67
84
|
__GetEvent(e: LynxElement, eventType: string, eventName: string): {
|
|
@@ -76,7 +93,7 @@ export declare const initElementTree: () => {
|
|
|
76
93
|
__SetGestureDetector(e: LynxElement, id: number, type: number, config: any, relationMap: Record<string, number[]>): void;
|
|
77
94
|
__GetDataset(e: LynxElement): DOMStringMap;
|
|
78
95
|
__RemoveElement(parent: LynxElement, child: LynxElement): void;
|
|
79
|
-
__InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement): void;
|
|
96
|
+
__InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement | undefined): void;
|
|
80
97
|
__ReplaceElement(newElement: LynxElement, oldElement: LynxElement): void;
|
|
81
98
|
__FlushElementTree(): void;
|
|
82
99
|
__UpdateListComponents(_list: LynxElement, _components: string[]): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/testing-environment",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "A subset of a Lynx environment to be useful for testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lynx",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
"CHANGELOG.md"
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@testing-library/jest-dom": "^6.
|
|
50
|
+
"@testing-library/jest-dom": "^6.9.0",
|
|
51
51
|
"@types/jsdom": "^21.1.7",
|
|
52
52
|
"rsbuild-plugin-publint": "0.3.3"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"api-extractor": "api-extractor run --verbose",
|
|
56
56
|
"build": "rslib build",
|
|
57
|
-
"dev": "rslib build --watch"
|
|
57
|
+
"dev": "rslib build --watch",
|
|
58
|
+
"test": "vitest"
|
|
58
59
|
}
|
|
59
60
|
}
|