'How to test TaskEither form fp-ts with jest

I am new to fp-ts. Let's say I have a function (path: string) => TaskEither<Erorr, T> which reads and parses config, and I want to write a test for that.

So far I have:

test('Read config', done => {
  interface Config {
    fld1: string
    fld2: {
      fld: 3
    }
  }

  pipe(
    readConfig<Config>("resources/test-config.toml"),
    TE.fold(
      err => T.of(done(err)),
      toml => T.of(() => {
        expect(toml).toBe({})
        done()
      })
    )
  )

})

But it fails due to timeout. And also I am unsure if I implemented fold correctly. How do fold TaskEither to Task in general and then call it asynchronously?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source