Entering the world of fp-ts, I encounter a function
(path: string) => TaskEither<Erorr, T>
that reads and parses configuration data. Now, my challenge is to create a test for this process.
Here is what I have tried so far:
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()
})
)
)
})
However, the test fails due to a timeout issue. Also, there's uncertainty about whether the fold implementation is correct. How can I properly fold from TaskEither
to Task
and execute it asynchronously?