Repository: remarkablemark/html-react-parser
Pull request #183 (2020-11-27 02:01:05)

build: upgrade dependencies and fix tests
## What is the motivation for this pull request?

build: upgrade `package.json` dependencies and fix tests

## What is the current behavior?

Dependencies are behind and Preact tests are failing

## What is the new behavior?

Dependencies are up-to-date and Preact tests are fixed

```
@types/htmlparser2                 3.10.1  →   3.10.2
@commitlint/cli                    ^8.3.5  →  ^11.0.0
@commitlint/config-conventional    ^8.3.4  →  ^11.0.0
@rollup/plugin-commonjs           ^12.0.0  →  ^16.0.0
@rollup/plugin-node-resolve        ^8.0.0  →  ^10.0.0
@types/react                     ^16.9.35  →  ^17.0.0
@typescript-eslint/parser          ^3.1.0  →   ^4.8.2
dtslint                           ^3.6.10  →   ^4.0.6
eslint                             ^7.1.0  →  ^7.14.0
eslint-plugin-prettier             ^3.1.3  →   ^3.1.4
husky                              ^4.2.5  →   ^4.3.0
jest                              ^26.0.1  →  ^26.6.3
lint-staged                       ^10.2.7  →  ^10.5.2
preact                            ^10.4.4  →  ^10.5.7
prettier                           ^2.0.5  →   ^2.2.0
react                                 ^16  →      ^17
react-dom                             ^16  →      ^17
rollup                            ^2.12.1  →  ^2.33.3
typescript                         ^3.9.3  →   ^4.1.2
```

## Checklist:

- [x] Tests



Patch:
diff --git a/package.json b/package.json
index 3ec05ce..8803af2 100644
--- a/package.json
+++ b/package.json
@@ -32,34 +32,34 @@
     "dom"
   ],
   "dependencies": {
-    "@types/htmlparser2": "3.10.1",
+    "@types/htmlparser2": "3.10.2",
     "html-dom-parser": "0.3.0",
     "react-property": "1.0.1",
     "style-to-js": "1.1.0"
   },
   "devDependencies": {
-    "@commitlint/cli": "^8.3.5",
-    "@commitlint/config-conventional": "^8.3.4",
-    "@rollup/plugin-commonjs": "^12.0.0",
-    "@rollup/plugin-node-resolve": "^8.0.0",
-    "@types/react": "^16.9.35",
-    "@typescript-eslint/parser": "^3.1.0",
+    "@commitlint/cli": "^11.0.0",
+    "@commitlint/config-conventional": "^11.0.0",
+    "@rollup/plugin-commonjs": "^16.0.0",
+    "@rollup/plugin-node-resolve": "^10.0.0",
+    "@types/react": "^17.0.0",
+    "@typescript-eslint/parser": "^4.8.2",
     "benchmark": "^2.1.4",
-    "dtslint": "^3.6.10",
-    "eslint": "^7.1.0",
-    "eslint-plugin-prettier": "^3.1.3",
-    "husky": "^4.2.5",
-    "jest": "^26.0.1",
-    "lint-staged": "^10.2.7",
-    "preact": "^10.4.4",
-    "prettier": "^2.0.5",
-    "react": "^16",
-    "react-dom": "^16",
+    "dtslint": "^4.0.6",
+    "eslint": "^7.14.0",
+    "eslint-plugin-prettier": "^3.1.4",
+    "husky": "^4.3.0",
+    "jest": "^26.6.3",
+    "lint-staged": "^10.5.2",
+    "preact": "^10.5.7",
+    "prettier": "^2.2.0",
+    "react": "^17",
+    "react-dom": "^17",
     "rimraf": "^3.0.2",
-    "rollup": "^2.12.1",
+    "rollup": "^2.33.3",
     "rollup-plugin-terser": "^7.0.2",
     "standard-version": "5",
-    "typescript": "^3.9.3"
+    "typescript": "^4.1.2"
   },
   "peerDependencies": {
     "react": "^0.14 || ^15 || ^16 || ^17"


Test patch:
diff --git a/test/dom-to-react.test.js b/test/dom-to-react.test.js
index e719b99..af90462 100644
--- a/test/dom-to-react.test.js
+++ b/test/dom-to-react.test.js
@@ -95,19 +95,27 @@ describe('DOM to React', () => {
     const Preact = require('preact');
 
     it('converts with React (default)', () => {
-      const html = data.html.single;
-      const reactElement = domToReact(htmlToDOM(html));
+      const reactElement = domToReact(htmlToDOM(data.html.single));
 
       expect(React.isValidElement(reactElement)).toBe(true);
+      expect(Preact.isValidElement(reactElement)).toBe(false);
+
       expect(reactElement).toEqual(React.createElement('p', {}, 'foo'));
     });
 
     it('converts with Preact instead of React', () => {
-      const html = data.html.single;
-      const preactElement = domToReact(htmlToDOM(html), { library: Preact });
+      const parsedElement = domToReact(htmlToDOM(data.html.single), {
+        library: Preact
+      });
+      const preactElement = Preact.createElement('p', {}, 'foo');
+
+      expect(React.isValidElement(parsedElement)).toBe(false);
+      expect(Preact.isValidElement(parsedElement)).toBe(true);
 
-      expect(Preact.isValidElement(preactElement)).toBe(true);
-      expect(preactElement).toEqual(Preact.createElement('p', {}, 'foo'));
+      // remove `__v` key since it's causing test equality to fail
+      delete parsedElement.__v;
+      delete preactElement.__v;
+      expect(parsedElement).toEqual(preactElement);
     });
   });
 
diff --git a/test/html-to-react.test.js b/test/html-to-react.test.js
index 5707813..d62c451 100644
--- a/test/html-to-react.test.js
+++ b/test/html-to-react.test.js
@@ -168,13 +168,19 @@ describe('HTML to React', () => {
     });
 
     describe('library', () => {
+      const Preact = require('preact');
+
       it('converts with Preact instead of React', () => {
-        const Preact = require('preact');
-        const html = data.html.single;
-        const options = { library: Preact };
-        const preactElement = parse(html, options);
+        const parsedElement = parse(data.html.single, { library: Preact });
+        const preactElement = Preact.createElement('p', {}, 'foo');
+
+        expect(React.isValidElement(parsedElement)).toBe(false);
+        expect(Preact.isValidElement(parsedElement)).toBe(true);
 
-        expect(preactElement).toEqual(Preact.createElement('p', {}, 'foo'));
+        // remove `__v` key since it's causing test equality to fail
+        delete parsedElement.__v;
+        delete preactElement.__v;
+        expect(parsedElement).toEqual(preactElement);
       });
     });