{"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.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install preact-test-utils"],"cli":null},"imports":["import TestUtils from 'react-addons-test-utils';","import ShallowRenderer from 'react-addons-test-utils/shallow';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}