@happy-dom/jest-environment 7.2.0 → 7.4.0
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@happy-dom/jest-environment",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.4.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom/tree/master/packages/jest-environment",
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"@jest/environment": "^27.5.1",
|
53
53
|
"@jest/fake-timers": "^27.5.1",
|
54
54
|
"@jest/types": "^27.5.1",
|
55
|
-
"happy-dom": "^7.
|
55
|
+
"happy-dom": "^7.4.0",
|
56
56
|
"jest-mock": "^27.5.1",
|
57
57
|
"jest-util": "^27.5.1"
|
58
58
|
},
|
@@ -63,8 +63,11 @@
|
|
63
63
|
"@angular/platform-browser": "^10.0.7",
|
64
64
|
"@angular/platform-browser-dynamic": "^10.0.7",
|
65
65
|
"@lit/reactive-element": "^1.3.1",
|
66
|
-
"@
|
66
|
+
"@testing-library/react": "^12.1.2",
|
67
|
+
"@testing-library/user-event": "^14.4.3",
|
67
68
|
"@types/node": "^15.6.0",
|
69
|
+
"@types/react": "^17.0.2",
|
70
|
+
"@types/react-dom": "^17.0.2",
|
68
71
|
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
69
72
|
"@typescript-eslint/parser": "^5.16.0",
|
70
73
|
"cpy": "^8.1.2",
|
@@ -90,5 +93,5 @@
|
|
90
93
|
"vue": "^3.2.31",
|
91
94
|
"zone.js": "^0.10.3"
|
92
95
|
},
|
93
|
-
"gitHead": "
|
96
|
+
"gitHead": "0ab37b11eb1ca51950761483fee664a5ea5052d2"
|
94
97
|
}
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
|
-
import
|
3
|
+
import * as ReactTestingLibrary from '@testing-library/react';
|
4
|
+
import ReactTestingLibraryUserEvent from '@testing-library/user-event';
|
5
|
+
import { ReactDivComponent, ReactSelectComponent, ReactInputComponent } from './ReactComponents';
|
6
|
+
|
7
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
8
|
+
|
9
|
+
const TESTING_LIBRARY_USER = ReactTestingLibraryUserEvent.setup();
|
4
10
|
|
5
11
|
describe('React', () => {
|
6
12
|
let appElement: Element;
|
@@ -15,20 +21,26 @@ describe('React', () => {
|
|
15
21
|
});
|
16
22
|
|
17
23
|
it('Tests integration.', () => {
|
18
|
-
ReactDOM.render(<
|
24
|
+
ReactDOM.render(<ReactDivComponent />, appElement);
|
19
25
|
expect(appElement.innerHTML).toBe('<div>Test</div>');
|
20
26
|
});
|
21
27
|
|
22
28
|
it('Can unmount a component.', () => {
|
23
|
-
ReactDOM.render(<
|
29
|
+
ReactDOM.render(<ReactDivComponent />, appElement);
|
24
30
|
ReactDOM.unmountComponentAtNode(appElement);
|
25
31
|
expect(appElement.innerHTML).toBe('');
|
26
32
|
});
|
27
33
|
|
28
|
-
it('
|
29
|
-
ReactDOM.render(<ReactSelectComponent />, appElement);
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
it('Handles adding and removing event listeners.', () => {
|
35
|
+
ReactDOM.render(<ReactSelectComponent onChange={() => {}} />, appElement);
|
36
|
+
});
|
37
|
+
|
38
|
+
it('Testing library handles input', async () => {
|
39
|
+
const { getByPlaceholderText } = ReactTestingLibrary.render(<ReactInputComponent />);
|
40
|
+
const input: HTMLInputElement = getByPlaceholderText('input field') as HTMLInputElement;
|
41
|
+
|
42
|
+
await TESTING_LIBRARY_USER.type(input, 'hello');
|
43
|
+
|
44
|
+
expect(input.value).toBe('hello');
|
33
45
|
});
|
34
46
|
});
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
4
|
+
|
5
|
+
/**
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
export class ReactDivComponent extends React.Component<{}, {}> {
|
9
|
+
public $props = {};
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @override
|
13
|
+
*/
|
14
|
+
public render(): React.ReactElement {
|
15
|
+
return <div>Test</div>;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
const OPTIONS = [
|
20
|
+
{ value: 't1', label: 'test 1' },
|
21
|
+
{ value: 't2', label: 'test 2' }
|
22
|
+
];
|
23
|
+
|
24
|
+
/**
|
25
|
+
*
|
26
|
+
*/
|
27
|
+
export class ReactSelectComponent extends React.Component<
|
28
|
+
{
|
29
|
+
value?: string;
|
30
|
+
onChange?: (value: string) => void;
|
31
|
+
},
|
32
|
+
{}
|
33
|
+
> {
|
34
|
+
public $props = {
|
35
|
+
value: OPTIONS[0].value,
|
36
|
+
onChange: null
|
37
|
+
};
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @override
|
41
|
+
*/
|
42
|
+
public render(): React.ReactElement {
|
43
|
+
return (
|
44
|
+
<select
|
45
|
+
value={this.props.value}
|
46
|
+
onChange={
|
47
|
+
this.props.onChange
|
48
|
+
? (event: React.ChangeEvent) =>
|
49
|
+
this.props.onChange((event.target as HTMLSelectElement).value)
|
50
|
+
: undefined
|
51
|
+
}
|
52
|
+
>
|
53
|
+
{OPTIONS.map((option) => (
|
54
|
+
<option key={option.value} value={option.value}>
|
55
|
+
{option.label}
|
56
|
+
</option>
|
57
|
+
))}
|
58
|
+
</select>
|
59
|
+
);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
*
|
65
|
+
*/
|
66
|
+
export class ReactInputComponent extends React.Component<{}, {}> {
|
67
|
+
public $props = {};
|
68
|
+
|
69
|
+
/**
|
70
|
+
* @override
|
71
|
+
*/
|
72
|
+
public render(): React.ReactElement {
|
73
|
+
return <input placeholder="input field" />;
|
74
|
+
}
|
75
|
+
}
|
package/test/tsconfig.json
CHANGED
@@ -1,25 +1,41 @@
|
|
1
1
|
{
|
2
|
-
"extends": "../tsconfig.json",
|
3
2
|
"compilerOptions": {
|
4
3
|
"outDir": "../tmp",
|
5
|
-
"rootDir": "
|
4
|
+
"rootDir": ".",
|
6
5
|
"tsBuildInfoFile": "../tmp/.tsbuildinfo-test",
|
6
|
+
"target": "es2020",
|
7
|
+
"declaration": true,
|
8
|
+
"module": "CommonJS",
|
9
|
+
"moduleResolution": "node",
|
10
|
+
"esModuleInterop": true,
|
11
|
+
"experimentalDecorators": true,
|
12
|
+
"allowSyntheticDefaultImports": true,
|
13
|
+
"resolveJsonModule": true,
|
14
|
+
"noUnusedLocals": true,
|
15
|
+
"noUnusedParameters": true,
|
16
|
+
"removeComments": false,
|
17
|
+
"preserveConstEnums": true,
|
18
|
+
"sourceMap": true,
|
19
|
+
"skipLibCheck": true,
|
20
|
+
"baseUrl": ".",
|
21
|
+
"composite": true,
|
22
|
+
"incremental": true,
|
7
23
|
"jsx": "react",
|
24
|
+
"types": [
|
25
|
+
"jest"
|
26
|
+
],
|
8
27
|
"lib": [
|
9
28
|
"es2015",
|
10
29
|
"es2016",
|
11
30
|
"es2017",
|
12
31
|
"dom"
|
13
|
-
],
|
14
|
-
"types": [
|
15
|
-
"jest"
|
16
32
|
]
|
17
33
|
},
|
18
34
|
"include": [
|
19
35
|
"@types/node",
|
20
36
|
"@types/jest",
|
21
|
-
|
22
|
-
|
23
|
-
"
|
37
|
+
"@types/react",
|
38
|
+
"@types/react-dom",
|
39
|
+
"."
|
24
40
|
]
|
25
41
|
}
|
@@ -1,32 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
|
3
|
-
/**
|
4
|
-
*
|
5
|
-
*/
|
6
|
-
export default class ReactComponent extends React.Component<{}, void> {
|
7
|
-
/**
|
8
|
-
* @override
|
9
|
-
*/
|
10
|
-
public render(): unknown {
|
11
|
-
return <div>Test</div>;
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|
15
|
-
/**
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
export class ReactSelectComponent extends React.Component<{}, void> {
|
19
|
-
/**
|
20
|
-
* @override
|
21
|
-
*/
|
22
|
-
public render(): unknown {
|
23
|
-
return (
|
24
|
-
<>
|
25
|
-
<select value="t2" onChange={() => {}}>
|
26
|
-
<option value="t1">test 1</option>
|
27
|
-
<option value="t2">test 2</option>
|
28
|
-
</select>
|
29
|
-
</>
|
30
|
-
);
|
31
|
-
}
|
32
|
-
}
|