Effect CommunityEC
Effect Community•3mo ago•
9 replies
James!

Missing `it.live` in `it.layer` for logging in tests; alternatives?

When using it.layer, the it instance it provides to the child tests does not have the it.live function which prevents us from seeing any logs in our tests.

describe('Happy path', () => {
    it.layer(
      SomeService.DefaultWithoutDependencies.pipe(
        Layer.provide(
          Layer.mock(Serv, {
            _tag: 'Serv',
            ...mock
          })
        )
      )
    )('....', (it) => {
      it.live('....', // `it.live` does not exist when using `it` from the layer, so forced to use `it.effect` which does not print test output
        Effect.fnUntraced(function* () {
       // All logs, etc. are not logged when using it.effect


is there an alternative way that's suggested 🤔

----
Dropping the use of `it.layer` & providing the layer directly to the Effect also works

const happyPathLayer = SomeService.DefaultWithoutDependencies.pipe(
        Layer.provide(
          Layer.mock(Serv, {
            _tag: 'Serv',
            ...mock
          })
        )
      )

it.live('...', Effect.fn(function*() {

   const service = yield* Service.pipe(Effect.provide(happyPathLayer))
})
Was this page helpful?