binygal / jest-runner-flowtype

Jest runner for running flowtype tests using jest as a platform
26 stars 10 forks source link

The README doesn't have an example of normal operation #12

Open kumar303 opened 6 years ago

kumar303 commented 6 years ago

I'd like to try this out for my project but it doesn't seem to work and I'm not even sure what to look for. What does normal operation look like? It would help if the README had an example.

To test things, I broke my code so that flow --colors=always in my root directory outputs some errors.

Flow output ``` Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/amo/components/AddonReviewCard/index.js:102:57 Cannot get review.id because: • property id is missing in undefined [1]. • property id is missing in null [2]. [1][2] 51│ review?: UserReviewType | null, : 99│ event.preventDefault(); 100│ 101│ //invariant(review, 'review is required'); 102│ dispatch(cancelDeleteAddonReview({ reviewId: review.id })); 103│ }; 104│ 105│ onClickToDeleteReview = (event: SyntheticEvent) => { Found 2 errors ```

I installed with yarn add --dev jest-runner-flowtype and added jest-flowrunner.config.js to my directory with this content:

module.exports = {
  runner: "jest-runner-flowtype"
};

I ran: yarn jest --config jest-flowrunner.config.js but all I get is this output:

yarn run v1.9.4
$ /Users/kumar/dev/addons-frontend/node_modules/.bin/jest --config jest-flowrunner.config.js
 PASS  config/test.js
  ✓  (157ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.175s, estimated 1s
Ran all test suites.
✨  Done in 0.81s.

I expected to see some Flow errors. Any ideas? config/test.js is a path to a file in my project. I also tried setting runner in my existing config but, still, I didn't see a report of Flow errors. The output was different.

Node version: v8.11.4 Flow version: 0.83.0 Jest version: 23.1.0

binygal commented 6 years ago

The following is an output for a simple (failing) test program. Can you create a simple project that reproduce the problem and share the link? I will be happy to fix it.

screen shot 2018-10-15 at 19 08 38
kumar303 commented 6 years ago

Can you create a simple project that reproduce the problem and share the link?

Sure. Here's one:

flow-jest-scratch.zip

I started by running yarn (version 1.9.4) on Node v8.11.4.

After that I ran flow, which outputs:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ index.js:4:16

Cannot coerce thing to string because object literal [1] should not be coerced.

     1│ /* @flow */
     2│
 [1] 3│ const thing = {};
     4│ console.log(`${thing}`);
     5│
     6│ exports.thing = thing;
     7│

Found 1 error

If I run jest or jest --config jest.config.js all I see is this:

 PASS  ./test_index.js
  ✓  (2858ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.875s
Ran all test suites.

I would expect to see the same Flow errors.

binygal commented 6 years ago

I found the problem. For some reason I had outdated version of flow. I see that the new flow output is changed so I parse the output incorrectly. I will fix it.