Open rapowell9 opened 4 years ago
Thanks @rapowell9 for reporting this. We just start re-write the jest tester from scratch since it's pretty buggy right now. We will release a new version soon which will be much more stable. We will take this bug into account as well. @JoshK2 FYI. @davidfirst please take a look, I'm not sure it's jest bug, it might be bit's bug.
Describe the bug
I have a few small react components, some of them with test cases. When the I use the bit test and individually pass each id in, they all pass. However, if I try to tag or test them all at once, some of the tests will fail. The failing tests throw a react-test-renderer error, see below, suggesting a problem with the imports. The conflict seems to be caused by the fact that the test file uses a default import to import the component, while another component imports the component with an
import { _component_ } from
statement, again, see below.Steps to Reproduce
Download TestingError.zip, extract the files and open the TEST directory TestingError.zip
In the TEST directory, run
bit init
andbit import -t bit.envs/testers/jest
.The compiler has a rawConfig setting in the package.json. If you import the compiler(v3.1.39) with
bit import -c bit.envs/compilers/react-typescript
, this configuration will be overwritten and the build will fail, so be sure to restore the configuration after importing. Alternatively, runningbit test
appears to automatically import the compiler(v3.1.31) without overriding the configuration, but the build will initially fail. However, running it again will work as described below.There are 3 components: box, label, and bar. Run
bit test box
, the tests will all pass.Run either
bit test
orbit tag
, and the tests for box will failExpected Behavior
The tests should have the same results whether they are run independently or as a group.
Screenshots, exceptions and logs
Test fails with this error:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Import from test file:
import Box from "../src/components/box"
Import from other component:
import {Box, IBoxProps} from './box'
Component exports:
export interface IBoxProps {...}
export class Box extends React.Component<IBoxProps, {}> {...}
export default Box
Specifications
EDIT: Realized my package.json had a different compiler version than I listed. Updated to reflect that, but the issue occurs with both versions