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

bind additional Assert functions #29

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

illusionalsagacity
Copy link
Contributor

  • notEqual
  • notDeepEqual
  • strictEqual
  • notStrictEqual
  • deepStrictEqual
  • fail

Copy link
Owner

@cometkim cometkim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but can you replace it with t->expect style?


Maybe I should change the binding to t => x => expected instead of (t, x) => expected later version 🤔

- notEqual
- notDeepEqual
- strictEqual
- notStrictEqual
- deepStrictEqual
- fail
@illusionalsagacity illusionalsagacity force-pushed the additional-assertion-bindings branch from e69036e to adfddaa Compare January 22, 2025 02:58
@illusionalsagacity
Copy link
Contributor Author

Maybe I should change the binding to t => x => expected instead of (t, x) => expected later version 🤔

Hmm, I kinda like that, you could alias expect in the start of your test function more easily that way too:

test("blah", t => {
  let expect = expect(t)
  ...
})

@illusionalsagacity
Copy link
Contributor Author

@cometkim any others you think would be useful? I think these would be the most common for use in waitFor* or other exception-based callbacks in Vitest_Helpers. The number ones could be useful I suppose, but I figure it ought to be split into Int and Float (and I guess BigInt now too) sub-modules for those? for example:

let a = ref(0)
let b = ref(0.)
await waitFor(() => {
  Assert.Int.isAbove(a.contents, 0, ~message="a is 0")
})
await waitFor(() => {
  Assert.Float.isAbove(b.contents, 0., ~message="b is 0.")
})

@cometkim
Copy link
Owner

Well, I'm not a fan of exposing a bloated API surface upfront by providing bindings.

Some should strictly follow the binding style, but users should easily add or extend simple helper methods themselves. Most submodules of Assert as well as they are never associated with a test context.

@illusionalsagacity
Copy link
Contributor Author

Well, I'm not a fan of exposing a bloated API surface upfront by providing bindings.

Are there any functions in here you would prefer not to be merged? Regardless I will leave out any more, to your point they should be straightforward enough to bind in consumer's projects

@cometkim
Copy link
Owner

If you use it in your project and you want to upstream it. I will merge unless there is a style conflict. Otherwise we can open issue and discuss first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants