We need to figure out `test` extensions syntax
See original GitHub issueSome 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.
Issue Analytics
- State:
- Created 7 years ago
- Comments:32 (18 by maintainers)
Top GitHub Comments
So I propose:
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
Or maybe even