{"id":13806,"library":"preact-test-utils","title":"Preact Test Utilities (Legacy React Addons Compatibility)","description":"This package, `preact-test-utils` version 0.1.4, served as an early compatibility layer for testing Preact components by allowing users to alias `react-addons-test-utils` in their build configuration (e.g., Webpack). Its primary goal was to enable existing React testing setups that relied on `react-addons-test-utils` to function with Preact without significant code changes. However, `react-addons-test-utils` itself was officially deprecated by React in version 15.5.0 (around 2017) and its functionalities were migrated to `react-dom/test-utils` and `react-test-renderer/shallow`. Consequently, `preact-test-utils` is now obsolete and effectively abandoned. Modern Preact testing relies on `@testing-library/preact` which wraps the official `preact/test-utils` module provided by the Preact core, offering a more robust and idiomatic approach to component testing.","status":"abandoned","version":"0.1.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","next","preact-test-utils"],"install":[{"cmd":"npm install preact-test-utils","lang":"bash","label":"npm"},{"cmd":"yarn add preact-test-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add preact-test-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package primarily functioned as a Webpack alias for `react-addons-test-utils`. Direct imports from `preact-test-utils` itself were not the intended usage. The aliased `react-addons-test-utils` would then expose methods like `renderIntoDocument`, `Simulate`, etc.","wrong":"import { TestUtils } from 'preact-test-utils';","symbol":"TestUtils","correct":"import TestUtils from 'react-addons-test-utils';"},{"note":"For shallow rendering, `react-addons-test-utils` had a separate entry point. This package would have redirected this as well. Note that `shallowRenderer` was later moved to `react-test-renderer/shallow` in React.","symbol":"shallowRenderer","correct":"import ShallowRenderer from 'react-addons-test-utils/shallow';"}],"quickstart":{"code":"/* webpack.config.js (conceptual, highly outdated) */\nmodule.exports = {\n  // ... other webpack config\n  resolve: {\n    alias: {\n      'react-addons-test-utils': 'preact-test-utils'\n    }\n  }\n};\n\n/* Example test file (conceptual usage with the alias) */\nimport { h } from 'preact';\nimport { render } from 'preact';\n// Assuming the alias is set up in webpack, this would resolve to preact-test-utils\nimport TestUtils from 'react-addons-test-utils';\n\nfunction MyComponent({ name }) {\n  return <div>Hello, {name}</div>;\n}\n\ndescribe('MyComponent', () => {\n  test('should render correctly', () => {\n    const node = document.createElement('div');\n    // Using TestUtils from the aliased package\n    TestUtils.renderIntoDocument(<MyComponent name=\"World\" />, node);\n    expect(node.textContent).toBe('Hello, World');\n\n    // Modern approach with @testing-library/preact:\n    // const { getByText } = render(<MyComponent name=\"World\" />);\n    // expect(getByText('Hello, World')).toBeInTheDocument();\n  });\n});","lang":"javascript","description":"Demonstrates the required Webpack alias configuration for `preact-test-utils` and a conceptual test using the emulated `react-addons-test-utils` API. This approach is highly outdated."},"warnings":[{"fix":"Migrate your testing setup to `@testing-library/preact` which is the current recommended approach for testing Preact components. This library wraps `preact/test-utils` and provides a user-centric API.","message":"The underlying `react-addons-test-utils` package, which `preact-test-utils` aimed to mimic, was deprecated in React 15.5.0. Its functionalities were moved to `react-dom/test-utils` and `react-test-renderer/shallow`. Using this alias will likely lead to compatibility issues or reliance on deprecated APIs.","severity":"breaking","affected_versions":">=0.1.4"},{"fix":"Do not use this package. Adopt `@testing-library/preact` for all new and existing Preact component tests.","message":"This package is extremely old (version 0.1.4) and has not been maintained for many years. It predates significant advancements in both Preact and React testing practices.","severity":"gotcha","affected_versions":">=0.1.4"},{"fix":"Understand that usage involves configuring a module alias. However, this is not a recommended solution for modern Preact development.","message":"The provided README explicitly shows a Webpack alias configuration. This package does not provide direct exports under its own name for testing utilities, but rather acts as a redirection target for `react-addons-test-utils`.","severity":"gotcha","affected_versions":">=0.1.4"}],"env_vars":null,"search_vec":"'/preact':120 '/shallow':100 '/test-utils':94 '0.1.4':15 '15.5.0':82 '2017':84 'abandon':111 'addon':6,33,57,71 'alia':30 'allow':27 'approach':138 'around':83 'build':38 'chang':67 'code':66 'compat':7,20 'compon':25,140 'configur':39 'consequ':101 'core':131 'deprec':77 'dom':93 'e.g':40 'earli':19 'effect':110 'enabl':47 'exist':48 'function':61,87 'goal':44 'howev':68 'idiomat':137 'javascript':142 'layer':21 'legaci':4 'librari':119 'migrat':89 'modern':112 'modul':126 'next':143 'obsolet':108 'offer':132 'offici':76,124 'packag':9 'preact':1,11,24,63,103,113,130,145 'preact-test-util':10,102,144 'preact/test-utils':125 'primari':43 'provid':127 'react':5,32,49,56,70,79,92,97 'react-addons-test-util':31,55,69 'react-dom':91 'react-test-render':96 'reli':53,115 'render':99 'robust':135 'serv':16 'setup':51 'signific':65 'test':2,12,23,34,50,58,72,98,104,114,118,141,146 'testing-librari':117 'user':28 'util':3,13,35,59,73,105,147 'version':14,81 'webpack':41 'without':64 'wrap':122","created_at":"2026-04-20T01:56:24.511080+00:00","updated_at":"2026-04-20T01:56:24.511080+00:00","problems":[{"fix":"Ensure your Webpack configuration correctly aliases `react-addons-test-utils` to `preact-test-utils`. However, it is strongly advised to migrate to `@testing-library/preact` instead of troubleshooting this legacy setup.","cause":"The Webpack alias for `react-addons-test-utils` might not be correctly configured or the aliased `preact-test-utils` package is not correctly mocking the expected API.","error":"Cannot read property 'renderIntoDocument' of undefined"},{"fix":"This warning is inherent to using a deprecated API. The only real fix is to stop using `react-addons-test-utils` and by extension `preact-test-utils`, and instead adopt modern Preact testing solutions like `@testing-library/preact`.","cause":"This warning indicates that even with the alias, the underlying React/Preact environment or some other dependency is detecting the usage of the deprecated `react-addons-test-utils` pattern.","error":"Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/preact-test-utils","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}