Race Conditions with Layered Test Suites Using Shared File System

I have a mock implementation of an external service that is backed by a KeyValueStore.layerFileSystem.

I think I'm hitting race conditions when running tests like this:

import { describe, layer } from "@effect/vitest"
import { Effect } from "effect"
import { TestLayer } from "../../layers/TestLayer"

describe("Suite A", () => {
  layer(TestLayer)((it) => {
    it.effect(
      "suite a should...",
      Effect.fnUntraced(function*() {
        // Test code here
      })
    )
  })
})

describe("Suite B", () => {
  layer(TestLayer)((it) => {
    it.effect(
      "suite b should...",
      Effect.fnUntraced(function*() {
        // Test code here
      })
    )
  })
})


I think my usage of layer(...) within the test suite is creating the layers every time. And, this means that there are multiple layers referencing the same file(s) as a KV store.
Was this page helpful?