jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.12k stars 6.44k forks source link

[Feature]: Skip specific test before test #15115

Closed barakadax closed 3 months ago

barakadax commented 3 months ago

🚀 Feature Proposal

Having decorator that get a function that always returns a Boolean, if it returns true you should skip the test otherwise run that specific test.

Motivation

I deploy the same test solution to many environments to test them all, but some test are for specifically different environments, so they can be skipped in those environments

Example

lets say you run in 3 specific namespaces in k8s cluster, same solution same version deployed, but there is one test that can work only in 1 namespace because of deployment and versions, but the test exists in all the deployed

Pitch

I'm not sure it's specifically for the core, it can be added to jest-extended itself the only issue if it's a good feature or if only I need this.

mrazauskas commented 3 months ago

For inspiration. Here is how conditional tests are implemented in the Jest repo: https://github.com/jestjs/jest/blob/main/packages/test-utils/src/ConditionalTest.ts

barakadax commented 3 months ago

I did if statement in my code but wondering if I could do it more elegant, also, need to learn now what is test.only so thank you.

github-actions[bot] commented 2 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.