Hey :wave: Is it expected that `beforeTest` of a ...
# kotest
r
Hey 👋 Is it expected that
beforeTest
of a nested scope is not executed for child scopes when the default isolation mode is chosen? Example:
Copy code
// beforeTest on the most outer level at the top of the spec
beforeTest { ... }

describe("some scope") {
  beforeTest { ... }

  // for these tests, the outer level and "some scope" beforeTest functions are executed in order before each test
  it("test a") { ... }
  it("test b") { ... }

  describe("some deeper scope") {
    // for all these tests only the top level beforeTest is executed before each one, but the "some scope" one is never executed
    it("test c") { ... }
    it("test d") { ... }
  }
}
When I change to
IsolationMode.InstancePerLeaf
it works, but I don't really need separate instances, I just need the
beforeTests
of each parent to be executed for each test case. If this is a bug, I'm happy to create an issue.
s
This is a bug that would only affect the SingleInstance spec runner.
r
Thanks! I will try and reproduce in a minimal setup and create an issue.
Turns out changing the
IsolationMode
only worked by chance for my specific test class. I tested with a minimal setup again and it looks like a bug regardless of isolation mode. I created an issue: https://github.com/kotest/kotest/issues/1574
👍🏻 1
I think I found the issue in Kotest. Will open a PR.