Open jasonkuhrt opened 2 years ago
Extending context means that a sub-group of tests want to have the parent group context plus some more. Currently achieved via cumbersome means:
const ctx = konn.beforeEach(() => ({ a: 1 })) describe('sub', () => { const ctx2 = konn().beforeEach(() => ctx2) })
I fact this probably won't even work, consider the mixing of beforeAll and beforeEach
beforeAll
beforeEach
const ctx = konn.beforeEach(() => ({ a: 1 })) describe('sub', () => { const ctx2 = konn().beforeAll(() => ctx2).beforeAll((ctx) => ctx.a /* <-- bug! (undefined at runtime, statically appears there) */ ) })
That looks like trouble.
A first class way to extend context:
const ctx = konn.beforeEach(() => ({ a: 1 })) describe('sub', () => { const ctx2 = konn(ctx).beforeAll((ctx) => ctx.a /* <-- statically undefined, good, agrees with runtime */ ) })
Perceived Problem
Extending context means that a sub-group of tests want to have the parent group context plus some more. Currently achieved via cumbersome means:
I fact this probably won't even work, consider the mixing of
beforeAll
andbeforeEach
That looks like trouble.
Ideas / Proposed Solution(s)
A first class way to extend context: