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

Lost assertions in async tests #50

Closed
pygy opened this issue May 20, 2022 · 1 comment · Fixed by #58
Closed

Lost assertions in async tests #50

pygy opened this issue May 20, 2022 · 1 comment · Fixed by #58
Assignees
Labels
enhancement New feature or request

Comments

@pygy
Copy link
Member

pygy commented May 20, 2022

It is currently possible to have assertions that run after the test that defined them, and at that point, ospec is unacle to trace their origin.

One possibility to solve this would be to change the API to something tape-like:

o("test", o => {
  // this would either refuse to work
  setTimeout(()=>o(1).equals(false), 5)
})

If we were to implement this, we'd need a complimentary codemod to upgrade the test suites. If someone skilled in theses want to step up and write it would be most welcome. Otherwise I'll dive into it.

@pygy pygy self-assigned this May 20, 2022
@pygy pygy added the enhancement New feature or request label May 20, 2022
@pygy
Copy link
Member Author

pygy commented Jan 25, 2023

I'm in the process of implementing this as an opt-in, run-time option. I'll provide o.localAssertions and o.localAssertions which can be nested. o.localAssertions(true) at the root of a test suite will also be valid as a global switch.

o.localAssertions( ()=> {
  o("new style", o => {})
  o.globalAssertions(()=>{
    o("old-style", done => {done()})
  })
})

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 a pull request may close this issue.

1 participant