preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
949 stars 148 forks source link

Testing failure using alias #480

Closed jhjaylim closed 6 years ago

jhjaylim commented 6 years ago

I have been using Preact with alias. So I am doing

import React from "react"

The issue I have is that when I test with jest and enzyme, it gives me createElement() not found error When I use preact-compat-enzyme, then it gives me h not defined

It seems like testing tools are confused about what to do.

Is there a solution for this? Most of client code is already written, so If there is no simple solution (meaning some sort of plugins) ?

developit commented 6 years ago

@jhjaylim you're missing the import for your JSX function:

import { createElement }, React from 'react';

Either do that, or configure your JSX pragma to be "React.createElement":

/** @jsx React.createElement */