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.

We need to figure out `test` extensions syntax

See original GitHub issue

Some planned features require the way to attach methods to test, e.g. before or skip. For skip many frameworks use test postfix:

test.skip('Some name', t=> {..});

This approach is quite ergonomic since you don’t need to modify test code much: just add dot and skip. But the problem is that our directive may have parameters, e.g. before. skip can also have parameter to specify predicate that will allow you to choose in which browsers you need to skip tests. I’ve tried some variations, but none of them satisfies me:

1. Move body afterwards

test('Some test')
   .before(async t => {...})
   .skip(browserInfo => {...})
   .fn(async t => {
        // test code here
    });

Pros: Looks OK, kinda… Cons: If you have existing test you need a lot of modifications to the existing test code. fn looks a little bit akward.

2. Directives afterwards

test('Some test', async t => {
        // test code here
    })
   .before(async t => {...})
   .skip(browserInfo => {...});

Pros: Minimal modifications to the existing code to add directive Cons: Prerequisites of the test goes after the test.

3. Options object

test('Some test', {
    before: async t => {...},
    skip: browserInfo => {...}
}, async t => {
   // test code here
});

Pros: Minimal modifications to the existing code to add directive. Prerequisites goes before test. Cons: Looks a little bit weird. Inconsistent with fixture directive where we have chained syntax.

If you have any other ideas, please, share them.

\cc @DevExpress/testcafe

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:32 (18 by maintainers)

github_iconTop GitHub Comments

6reactions
inikulincommented, Oct 18, 2016

So I propose:

test `My test name` (async t => {
  // Test code
});

test `My other test` 
    .skip
    .before(() => { ... })
(async t => {
  // Test code
}); 

As a new recommended test declaration syntax (we’ll enforce it in the docs as well). Please add 👍 or 👎 on this comment if you aggree or disagree so I’ll be able to move it from proposal stage.

\cc @DevExpress/testcafe

1reaction
AndreyBelymcommented, Sep 27, 2016

Or maybe even

test `Test` (async t => {
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Extensions - Visual Studio Code
Visual Studio Code supports running and debugging tests for your extension. These tests will run inside a special instance of VS Code named...
Read more >
Testing Joomla Extensions with Codeception
Check the contents of the /tests/ folder in weblinks and try to understand the structure of the tests. For each function you have...
Read more >
Writing extensions just got easier - Visual Studio Blog
I 've a home-grown ORM tool that uses files with a basic syntax I originally came up with so long ago that JSON...
Read more >
10 Must-have VS Code Extensions for JavaScript Developers
In this article, I'll focus on a list of must-have VS Code extensions for JavaScript developers. Visual Studio Code is undoubtedly the most ......
Read more >
Extension Methods - Scala 3 - EPFL
The extension method syntax can also be used to define operators. ... To convert a reference to an extension method, the compiler has...
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