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

[💡 Feature]: Allow skipping anywhere in test execution #12770

Open
spencerlavallesonos opened this issue Apr 29, 2024 · 5 comments
Open

[💡 Feature]: Allow skipping anywhere in test execution #12770

spencerlavallesonos opened this issue Apr 29, 2024 · 5 comments
Labels
Discussion Idea 💡 A new feature idea

Comments

@spencerlavallesonos
Copy link

Is your feature request related to a problem?

The problem is that sometimes when running a test, it becomes evident while on the page, that the test cannot continue as desired data/ setup isn't possible (smoke test), one cannot skip the test unless at the spec context.

Describe the solution you'd like.

I would love some globally available variable for test or something similar so that anywhere during execution, a test can choose to skip itself.

This way somewhere in a test, one can just call test.skip()

Describe alternatives you've considered.

A current workaround is to pass the spec context to helper functions downstream

e.g.

test.spec.js
...
it(...) {
  doesAThing(variable, this);
  verifyDoesAThing(variable, this)
}

enabling the functions doesAThing(...) and verifyDoesAThing(...) to use the skip functionality like so:

doesAThing(variable, context) {
  //functionality
  
  context.skip()
}```

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@spencerlavallesonos spencerlavallesonos added Idea 💡 A new feature idea Needs Triaging ⏳ No one has looked into the issue yet labels Apr 29, 2024
@christian-bromann
Copy link
Member

that the test cannot continue as desired data/ setup isn't possible (smoke test), one cannot skip the test unless at the spec context.

I would say your expectation is failing then und you should have the test fail. Why would you prefer to skip it?

@christian-bromann christian-bromann added Information Missing and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 29, 2024
@spencerlavallesonos
Copy link
Author

that the test cannot continue as desired data/ setup isn't possible (smoke test), one cannot skip the test unless at the spec context.

I would say your expectation is failing then und you should have the test fail. Why would you prefer to skip it?

Sorry a better way to phrase it is, an expectation that enables the test to continue isn't possible, e.g. a product variant is out of stock, skip the test for that variant.

@christian-bromann
Copy link
Member

Do you see this type of feature implemented in other projects?

@spencerlavallesonos
Copy link
Author

I haven't seen it used before but would be beneficial. I understand that the lack of examples will make this request a low priority 🤷‍♂️

@christian-bromann
Copy link
Member

I will keep this open and would love other people to provide their opinion. I personally would say, if you run a test and it doesn't provide a DB state you can rely on, your test should fail. If you can manipulate the DB I recommend to use the mock command in v9 or v8 if you only run tests on Chrome only. Another more hacky way to do this is maybe doing this:

let hasProperTestState = false
before(async () => {
  hasPropertTestState = await checkTestState()
})

it('test', function () {
  if (!hasProperTestState) {
    return this.skip()
  }
  // ...
})

You can overwrite the it command to have this check automatically enabled for all it blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Idea 💡 A new feature idea
Projects
None yet
Development

No branches or pull requests

2 participants