envs
envs copied to clipboard
Jest + Typescript Error (Code 2)
Describe the bug
I'm following the doc, but when i run bit test
Steps to Reproduce
- bit import bit.envs/testers/jest -t
- bit import -c bit.envs/compilers/typescript
- bit add src/project --main src/project/index.ts --tests specs/hello-world.spec.ts --id project
- bit test project
Expected Behavior
Result of tests
Screenshots, exceptions and logs
Specifications
- Bit version: 14.7.1
- Node version: v10.16.3
- npm / yarn version: yarn 1.19.1
- Platform: Windows 10 Pro
- Compiler / Tester (include version): Jest + Ts
Additional context
I've already cleaned the project and restarted from scratch by running git init --reset-hard
and still doesnt work
Hi, I am also facing the same issue., However I am working on React app (with typescript) also I noticed you are using only typescript compiler. In case you also have a react app with typescript you need to use another compiler, react-typescript.
Hi, I am also facing the same issue., However I am working on React app (with typescript) also I noticed you are using only typescript compiler. In case you also have a react app with typescript you need to use another compiler, react-typescript.
Actually there´s no problem by using typescript compiler, as u can see in the doc it can handle react components too, anyway it happens on both compilers :(
Running bit build on the component provides a more detailed error message, and at least for my component it appears to be a problem with the compiler not finding the jest type definitions.
"Cannot find name 'test'. Do you need to install type definitions for a test runner? Try npm i @types/jest
or npm i @types/mocha
."
Adding an overrides clause to the bit config to add @types/jest to the dependencies fixed the error
you should add the jest types using the overrides feature. read more here
@GiladShoham I added overrides but another error pops up.
Here is the reproducible repo. I was simply adding one component and did a 'bit test'. https://github.com/wannadream/bit-dev-bug
Looks like tester cannot find React module?
Try changing the target and module props for the compiler as described in the bottom of this page https://bit.dev/bit/envs/compilers/typescript
I am using https://bit.dev/bit/envs/compilers/react-typescript, but I believe the TS compiler is the same as I see the dependency. Jest was not configured properly?
@itaymendel or anyone else, any updates/workarounds?
@itaymendel I'd also appreciate any updates or workarounds if you've got them, I'm having the same problem as @wannadream
I'm also having this problem as well. Are there any work arounds now?
What I am doing is to ignore test files when pushing component to Bit. We have CI with GitLab to handle unit testing. Awkward.
@saltman424 @Exitialis1 @rotimi-babalola @wannadream Have you tried to configure the target and module in the compiler config? Also, soon a much better version of the extensions infrastructure (along with a new jest version based on the new infra), is coming. I don't have an exact eta, but it will be much more powerful, extendable, performing and stable. I estimate it will take a few more weeks.
@GiladShoham Thank you for the update, I am not sure if I have or not, but I am happy waiting for the new version and running tests else where for now if the new version is only a few weeks away.
@Exitialis1 Sound like a good plan:) it will be really awesome with the new version. stay tuned:)
Any update on the new version?
Are there any updates on this at all?
Any update on the new version? Thanks