PageSourceSearch

https://kotest.io/assets/js/178b4115.a6eaff2a.js

js kotest.io collected 2026-10-03 21:57:16 UTC 3,585 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkkotestdocs=globalThis.webpackChunkkotestdocs||[]).push([[12394],{13354(e,t,n){n.r(t),n.d(t,{assets:()=>r,contentTitle:()=>d,default:()=>h,frontMatter:()=>a,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"framework/conditional/xmethods","title":"Conditional tests with X Methods","description":"An idea that is popular with Javascript testing frameworks is to allow the test keywords to be prefixed with \'x\' to disable the test, and any nested tests.","source":"@site/versioned_docs/version-5.6.x/framework/conditional/xmethods.md","sourceDirName":"framework/conditional","slug":"/framework/conditional/conditional-tests-with-x-methods.html","permalink":"/docs/5.6.x/framework/conditional/conditional-tests-with-x-methods.html","draft":false,"unlisted":false,"editUrl":"https://github.com/kotest/kotest/blob/master/documentation/versioned_docs/version-5.6.x/framework/conditional/xmethods.md","tags":[],"version":"5.6.x","frontMatter":{"id":"xmethods","title":"Conditional tests with X Methods","slug":"conditional-tests-with-x-methods.html","sidebar_label":"X Methods"},"sidebar":"framework","previous":{"title":"Focus and Bang","permalink":"/docs/5.6.x/framework/conditional/conditional-tests-with-focus-and-bang.html"},"next":{"title":"Spec Annotations","permalink":"/docs/5.6.x/framework/conditional/spec-annotations-conditional-evaluation.html"}}');var o=n(74848),i=n(28453);const a={id:"xmethods",title:"Conditional tests with X Methods",slug:"conditional-tests-with-x-methods.html",sidebar_label:"X Methods"},d=void 0,r={},l=[];function c(e){const t={a:"a",code:"code",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.p,{children:"An idea that is popular with Javascript testing frameworks is to allow the test keywords to be prefixed with 'x' to disable the test, and any nested tests."}),"\n",(0,o.jsx)(t.p,{children:"This is similar to using the bang character in the test name."}),"\n",(0,o.jsxs)(t.p,{children:["For example, with ",(0,o.jsx)(t.code,{children:"DescribeSpec"})," we can replace ",(0,o.jsx)(t.code,{children:"describe"})," with ",(0,o.jsx)(t.code,{children:"xdescribe"})," as in this example:"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-kotlin",children:'class XMethodsExample : DescribeSpec({\n\n  xdescribe("this block and it\'s children are now disabled") {\n    it("will not run") {\n      // disabled test\n    }\n  }\n\n})\n'})}),"\n",(0,o.jsx)(t.p,{children:"Similarly, we could add the prefix to a nested test:"}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-kotlin",children:'class XMethodsExample : DescribeSpec({\n\n  describe("this block is enabled") {\n    xit("will not run") {\n      // disabled test\n    }\n    it("will run") {\n       // enabled test\n    }\n  }\n\n})\n'})}),"\n",(0,o.jsxs)(t.p,{children:["See which specs support this, and the syntax required on the ",(0,o.jsx)(t.a,{href:"/docs/5.6.x/framework/testing-styles.html",children:"specs styles guide"}),"."]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(c,{...e})}):c(e)}},28453(e,t,n){n.d(t,{R:()=>a,x:()=>d});var s=n(96540);const o={},i=s.createContext(o);function a(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.