From d7364c5db5cf7329ff35936f0d5f12ff6fbd7226 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Wed, 18 May 2022 20:43:53 +0200 Subject: [PATCH 1/2] (chore) - use https for semantic release (#54) The current error message when publishing npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/ --- .npmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.npmrc b/.npmrc index d272289..1df2a6d 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,2 @@ -registry=http://registry.npmjs.org/ +registry=https://registry.npmjs.org/ package-lock=false From 3318e0dbf19d9668913e0645dc0f1c412de6a504 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 19 May 2022 03:20:09 -0400 Subject: [PATCH 2/2] fix: flush pending hooks effects in rerender (#32) Call preact/test-utils act which manages the same setupRerender behavior implemented previously in preact-testing-library, but also flushes any pending hook effects Co-authored-by: Nick McCurdy --- src/__tests__/rerender.js | 18 ++++++++++++++++++ src/pure.js | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/__tests__/rerender.js b/src/__tests__/rerender.js index a8e321e..b31ae6c 100644 --- a/src/__tests__/rerender.js +++ b/src/__tests__/rerender.js @@ -1,5 +1,6 @@ import '@testing-library/jest-dom/extend-expect' import { h } from 'preact' +import { useState, useEffect } from 'preact/hooks' import { render } from '..' test('rerender will re-render the element', () => { @@ -12,6 +13,23 @@ test('rerender will re-render the element', () => { expect(container.firstChild).toHaveTextContent('hey') }) +test('rerender will flush pending hooks effects', async () => { + const Component = () => { + const [value, setValue] = useState(0) + useEffect(() => { + const timeoutId = setTimeout(() => setValue(1), 0) + return () => clearTimeout(timeoutId) + }) + + return value + } + + const { rerender, findByText } = render() + rerender() + + await findByText('1') +}) + test('hydrate will not update props until next render', () => { const initialInputElement = document.createElement('input') const container = document.createElement('div') diff --git a/src/pure.js b/src/pure.js index 56d7d79..c5d809e 100644 --- a/src/pure.js +++ b/src/pure.js @@ -69,7 +69,7 @@ function render ( : console.log(prettyDOM(el, maxLength, options)), unmount: () => preactRender(null, container), rerender: (rerenderUi) => { - setupRerender()() + act(() => {}) render(wrapUiIfNeeded(rerenderUi), { container, baseElement }) // Intentionally do not return anything to avoid unnecessarily complicating the API. // folks can use all the same utilities we return in the first place that are bound to