Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow easy context extension #31

Open
jasonkuhrt opened this issue Feb 10, 2022 · 0 comments
Open

Allow easy context extension #31

jasonkuhrt opened this issue Feb 10, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@jasonkuhrt
Copy link
Member

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:

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

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.

Ideas / Proposed Solution(s)

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 */ )
})
@jasonkuhrt jasonkuhrt added the enhancement New feature or request label Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant