question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Prebound assertion functions

See original GitHub issue

It would be useful and functional to be able to destructure test functions such as pass, fail, deepEqual, it etc. from the test object argument passed into the test function. Currently they are not bound to the test context but could probably be provided pre-bound.

test(({ deepEqual }) => {
    deepEqual([1, 2], [1, 2]);
});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
novemberborncommented, Mar 22, 2017

With the recent assertion refactor I think we can make it so the assertion knows whether it’s bound or not, so unbound enhanced assertions know that they’re not wrapped by power-assert.

That said I’m somewhat concerned about the performance impact, and not convinced about the value-add.

1reaction
sindresorhuscommented, Feb 11, 2017

I don’t really see how that is any more readable than:

test(t => {
    t.deepEqual([1, 2], [1, 2]);
});

It actually get’s very verbose when you use multiple assertions, which is common:

test(({ deepEqual, is, throws }) => {
    deepEqual([1, 2], [1, 2]);
    is(1, 1);
    throws(() => foo());
});

Let’s see what the other team members think.

Maybe you can elaborate on why you want it this way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5. Add Assertions to Functional Tests | ReadyAPI Documentation
In Functional Tests, select GET Request in the Navigator panel and click Add Assertion: · In the dialog, select the SLA category on...
Read more >
About Queries | Testing Library
This is useful for asserting an element that is not present. ... query that is pre-bound to document.body (using the within functionality).
Read more >
gMock Cookbook | GoogleTest
Mocking Non-virtual Methods. gMock can mock non-virtual functions to be used in Hi-perf dependency injection. ... Using Matchers in googletest Assertions.
Read more >
tap - npm
Works with all exception-throwing assertion libraries (chai, should, node's built-in require('assert') , or just throwing yourself) but also ...
Read more >
Using React Testing Library and Jest with AG Grid
I want to write tests that assert AG Grid renders the expected data, ... But... ideally write a test function to cover the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found