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

Restrict test modifier chaining #1182

Closed
novemberborn opened this issue Jan 13, 2017 · 2 comments · Fixed by #1670
Closed

Restrict test modifier chaining #1182

novemberborn opened this issue Jan 13, 2017 · 2 comments · Fixed by #1670
Assignees
Labels
bug current functionality does not work as desired help wanted scope:test-interface
Milestone

Comments

@novemberborn
Copy link
Member

novemberborn commented Jan 13, 2017

Currently test modifiers allow silly and confusing combinations. We have linting rules to warn about them, and disallow some of them in the type definitions. We should go further and restrict the modifier chains so only useful combinations are allowed, but provide useful error feedback if disallowed combinations are used.

Examples of silly chains:

  • test.always.afterEach.cb()
  • test.after.test()
  • test.always.always.serial.always.afterEach(() => {})

Examples of confusing chains:

See also the discussion in #1005.

@novemberborn novemberborn added this to the 1.0 milestone Aug 28, 2017
@novemberborn novemberborn added scope:test-interface bug current functionality does not work as desired labels Oct 26, 2017
novemberborn added a commit that referenced this issue Jan 29, 2018
Stop deriving a title from the test implementation function's name.

Note that this can't quite be expressed in the type definitions.
Hopefully when we tackle #1182 it'll be easier to write the appropriate
definition.
novemberborn added a commit that referenced this issue Jan 29, 2018
* Require tests to have titles

Stop deriving a title from the test implementation function's name.

Note that this can't quite be expressed in the type definitions.
Hopefully when we tackle #1182 it'll be easier to write the appropriate
definition.

* Require test titles to be unique

Fixes #1207.
novemberborn added a commit that referenced this issue Jan 29, 2018
Explicitly specify allowable chains, with some ground rules in mind:

Test chaining rules:

* serial must come at the start
* only and skip must come at the end
* failing must come at the end, but can be followed by only and skip
* only and skip cannot be chained together
* no repeating

Hook chaining rules:

* always comes immediately after "after hooks"
* skip must come at the end
* no only
* no repeating

Additionally:

* todo cannot be chained, except after serial
* all methods except for test are available on serial

This commit also removes now unnecessary assertions from TestCollection.

Fixes #1182.
@novemberborn
Copy link
Member Author

test.serial.afterEach() (#1178)

Whilst this one is potentially confusing, I don't want to stop people from using the import {serial as test} from 'ava' shorthand. It's not removed in #1670.

@novemberborn novemberborn modified the milestones: Priorities, 1.0 Jan 29, 2018
novemberborn added a commit that referenced this issue Jan 30, 2018
Explicitly specify allowable chains, with some ground rules in mind:

Test chaining rules:

* serial must come at the start
* only and skip must come at the end
* failing must come at the end, but can be followed by only and skip
* only and skip cannot be chained together
* no repeating

Hook chaining rules:

* always comes immediately after "after hooks"
* skip must come at the end
* no only
* no repeating

Additionally:

* todo cannot be chained, except after serial
* all methods except for test are available on serial

This commit also removes now unnecessary assertions from TestCollection.

Fixes #1182.
@novemberborn novemberborn self-assigned this Jan 31, 2018
novemberborn added a commit that referenced this issue Feb 4, 2018
Explicitly specify allowable chains, with some ground rules in mind:

Test chaining rules:

* `serial` must come at the start
* `only` and `skip` must come at the end
* `failing` must come at the end, but can be followed by `only` and `skip`
* `only` and `skip` cannot be chained together
* no repeating

Hook chaining rules:

* `always` comes immediately after "after hooks"
* `skip` must come at the end
* no `only`
* no repeating

Additionally:

* `todo` cannot be chained, except after `serial`
* hooks are not available on `serial`

This commit also removes now unnecessary assertions from TestCollection.

Fixes #1182.
@novemberborn
Copy link
Member Author

I don't want to stop people from using the import {serial as test} from 'ava' shorthand. It's not removed in #1670.

I've changed my mind on this. #1670 will remove hooks from test.serial, but #1684 will bring them back.

novemberborn added a commit that referenced this issue Feb 4, 2018
Explicitly specify allowable chains, with some ground rules in mind:

Test chaining rules:

* `serial` must come at the start
* `only` and `skip` must come at the end
* `failing` must come at the end, but can be followed by `only` and `skip`
* `only` and `skip` cannot be chained together
* no repeating

Hook chaining rules:

* `always` comes immediately after "after hooks"
* `skip` must come at the end
* no `only`
* no repeating

Additionally:

* `todo` cannot be chained, except after `serial`
* hooks are not available on `serial`

This commit also removes now unnecessary assertions from TestCollection.

Fixes #1182.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired help wanted scope:test-interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant