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

Async support (🚧WIP) #13

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

Async support (🚧WIP) #13

wants to merge 15 commits into from

Conversation

luttje
Copy link
Owner

@luttje luttje commented Dec 3, 2024

Will close #12. For now this still has many problems and missing features.

  • Bail early on failing tests
  • Use reporter to output test results
  • Fix test counts (not sure if they're correct atm, see Incorrect test count when nesting describe #10 too)
  • There's a lot of unused code and layers of abstractions that we can do without
  • setExpectedAssertionCount/incrementAssertionCount is tricky now that we have async. Somehow we need to scope that.
  • beforeAll is called too often causing a failing test atm
  • Create generic 'test/describe context' where assertion counts, isBeforeAllCalled, etc. can be stored. Only after this fix:
  • Retry failed tests

I think the most straight forward fix for tracking assertion counts, is to create a text context and bind and pass that to the test as an 'expect' parameter. That way it would know which assertions to count and increment.

Alternatively, a way that doesn't change the API, could be to keep track of test source code lines and have expect find which test it is called in that way.

local function getCallerFunctionLine()
    local info = debug.getinfo(3, "S") -- stack level 3 == caller of `expect`
    return info and info.linedefined
end

…ter to output, clean up unneeded abstractions for clarity,
…k), except for incrementAssertionCount requiring currentDescribeOrTest to be set, which is tricky if async callbacks can assert at any time
@luttje luttje added the enhancement New feature or request label Dec 3, 2024
@luttje luttje self-assigned this Dec 3, 2024
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

Successfully merging this pull request may close these issues.

Support testing async code with callbacks
1 participant